It's great to see more development of the language! MoonScript is great if you're looking for the niceness of CoffeeScript in an embedded environment (Lua's semantics also behave more sanely than Javascript's). I have roughly 5000 lines of MoonScript powering my side project [1], and it's been a pleasure to write.
Any thoughts of letting the 'do' keyword support coffeescript-style 'do' semantics as well? Invoking a multi-line anonymous function is currently a bit impractical, and allowing do to invoke a single function parameter would make that a lot nicer, and allow for capturing variable's in a closure more easily. Example from the coffeescript docs:
for filename in list
do (filename) ->
fs.readFile filename, (err, contents) ->
compile filename, contents.toString()
I've thought about this. It doesn't make as much sense in Lua. An iterated variable it gets it's own local assignment for each iteration. The variable isn't shared like JavaScript:
Here I create 10 functions closed on the loop value. Then I loop over them and call them all. In JavaScript this would print 10 10 times, but in Lua we get the 1 through 10.
Cool project! Just wondering why you decided to roll your own
parser. Is there a lua parser generator library?
I've been working on a source translator, sort of like coffeescript for VimL [1], and I can't imagine writing the parser myself instead a BNF grammar (but please correct me if I'm wrong, I only took a cursory look at the src)
I've assembled a few parsers using various tools, and I must say PEGs are my favorite. They are very flexible and performance is comparable. (even CoffeeScript 2.0 is being written with a PEG.)
Ah, ok cool. I haven't tried using PEGs and I don't even know the theory behind it, so I'm watching a video [1] by the author of LPEG now, which is quite good. Cheers!
CoffeeScript hides the most hideous warts of JavaScript. It's worth it because although messy as Hell, JS has an amazing ecosystem, most importantly/obvioulsy the ability to run in a client's browser.
If I get it right, MoonScript aims at doing the same for Lua. The difference is that (1) Lua ecosystem isn't nearly as unavoidable as JS' and (2) Although some design decisions in Lua aren't consensual, the one thing you cannot call the language is "messy". IMO, Lua's main drawback is that by being so flexible and lacking an interventionist benevolent dictator, it doesn't grow standard coding practices, as Python does. Of course, creating alternative syntaxes isn't likely to improve the matter.
But in the end, it's fun to write compilers, and this is a perfectly legitimate reason to write one.
The lua ecosystem is extremely simple to embed in a native application, which, as someone who has had to do it, is something that feels underappreciated. Python and javascript were harder to set up for embedding on the same computer, and all but impossible to cross-compile for iOS. The simplicity of using lua as a scripting language in larger applications makes it a great target for compilation.
MoonScript also gets rid of a lot of the more verbose parts of lua, and replaces them with CoffeeScript-like versions. For example: shorter anonymous function syntax, syntactically significant whitespace, default local variables.
You might as well ask what is so great about Lua. This kind of thin compiler is what you get when you want the semantics and the ecosystem of Lua but with a richer syntax.
Any thoughts of letting the 'do' keyword support coffeescript-style 'do' semantics as well? Invoking a multi-line anonymous function is currently a bit impractical, and allowing do to invoke a single function parameter would make that a lot nicer, and allow for capturing variable's in a closure more easily. Example from the coffeescript docs:
[1] http://www.codingspellbook.com/