Today marks MoonScript version 0.2.2, the CoffeeScript inspired language that compiles to Lua. It's been approximately 11 months since the last release, and I'd like to apologize for the long gap. Hopefully we'll see more frequent updates in the future.
You can follow me on twitter for updates or complaints. Also if you're
using MoonScript I'd love to hear about it: leafot@gmail.com.
You can find the full release notes on my blog: http://leafo.net/posts/moonscript_v022.html
Changes
- Compiled files will now implicitly return their last statement. Be careful, this might change what
require
returns.
New Things
The Language
- Added
continue
keyword for skipping the current iteration in a loop. - Added string interpolation.
- Added
do
expression and block. - Added
unless
as a block and line decorator. Is the inverse ofif
. - Assignment can be used in an
if
statement's expression. - Added
or=
andand=
operators. @@
can be prefixed in front of a name to access that name withinself.__class
@
and@@
can be used as values to referenceself
andself.__class
.- In class declarations it's possible to assign to the class object instead of the instance metatable by prefixing the key with
@
. - Class methods can access locals defined within the body of the class declaration.
- Super classes are notified when they are extended from with an
__inherited
callback. - Classes can now implicitly return and be expressions.
local
keyword returns, can be used for forward declaration or shadowing a variable.- String literals can be used as keys in table literals.
- Call methods on string literals without wrapping in parentheses:
"hello"\upper!
- Table comprehensions can return a single value that is unpacked into the key and value.
- The expression in a
with
statement can now be an assignment, to give a name to the expression that is being operated on.
The API
- The
load
functions can take an optional last argument of options.
The Tools
- The online compiler now runs through a web service instead of emscripten, should work reliably on any computer now.
- Windows binaries have been updated.
Bug Fixes
- Significantly improved the line number rewriter. It should now accurately report all line numbers.
- Generic
for
loops correctly parse for multiple values as defined in Lua. - Update expressions don't fail with certain combinations of precedence.
- All statements/expressions are allowed in a class body, not just some.
x = "hello" if something
will extract the declaration ofx
if it's not in scope yet. Preventing an impossible to access variable from being created.- varargs,
...
, correctly bubble up through automatically generated anonymous functions. - Compiler doesn't crash if you try to assign something that isn't assignable.
- Numerous other small fixes. See commit log.
Other Stuff
Since the past release I've written quite a bit of MoonScript. I wrote four games, feel free to check out the source code:
I've written a tutorial for installing MoonScript on the three main platforms, Windows, OSX, and Linux.
I've written a script and guide for running Lua on Heroku. Which lets us also run MoonScript. This opens up quite a few opportunities, more on that later.
Bitbucket now highlights MoonScript files. If you'd like to see MoonScript on GitHub say something here: github-linguist/linguist#246.
Thanks
That's all for this release. Thanks to everyone who submitted bugs and patches and provided feedback on GitHub. See you next release.