http://github.com/jedediah/prettyscript
It's only barely usable at this point and I've been too busy to work on it.
11–20 of 67 posts
http://github.com/jedediah/prettyscript
It's only barely usable at this point and I've been too busy to work on it.
JavaScript has always had a gorgeous object model hidden within Java-esque syntax. CoffeeScript is an attempt to expose the good parts of JavaScript through syntax that favors expressions over statements, cuts down on punctuation noise, and provides pretty function literals. This CoffeeScript: square: x => x * x. Compiles into this JavaScript: var square = function(x) { return x * x; }; If anyone has specific ideas a…
Splendid! This is what JS really needs, a thin layer to clean up the syntax and patch the quirks, without breaking anything. I made the same kind of thing using the actual Ruby parser: http://github.com/jedediah/prettyscript It's only barely usable at this point and I've been too busy to work on it.
CoffeeScript does this by using the AST to recursively push down returns and assignments requested from outside a block to the final line of each possible branch of execution:
http://jashkenas.github.com/coffee-script/#expressions
How are you doing it? Did you find any particularly tricky cases?
Heh... Might want to choose a file extension other than ".cs".
Heh... Might want to choose a file extension other than ".cs".
Heh... Might want to choose a file extension other than ".cs".
Yeah, all the good extensions are taken -- .cof and .cfs are already other things as well. None of the tooling in the compiler cares about what extension you use: you can call it .coffeescript if you'd like. I'm going to stick to .cs for the parallel to .js for the time being.
Beautiful! (I finally made it to the end of the article where you ask about block delimiting...) I think there are two issues, one being that '........' at the end of a large nested expression is ugly, the other being that it's hard to find the start and end of a block as it stands. Since you seem to borrow a lot from ruby, why not add {} and/or begin/end as options? I would definitely keep the period syntax around (…
Yeah, the periods to end block scope are the part of the syntax I'm the least happy with. I couldn't think of anything nicer without resorting to significant whitespace (which I'd like to avoid). I'd rather not add {/}, or begin/end, because it's easy to determine the beginning of the block, it's just closing it that we need a symbol for. In terms of style, you can certainly indent the period on it's own line if you…
JavaScript has always had a gorgeous object model hidden within Java-esque syntax. CoffeeScript is an attempt to expose the good parts of JavaScript through syntax that favors expressions over statements, cuts down on punctuation noise, and provides pretty function literals. This CoffeeScript: square: x => x * x. Compiles into this JavaScript: var square = function(x) { return x * x; }; If anyone has specific ideas a…