Skip to content

Releases: leafo/moonscript

MoonScript v0.5.0

26 Sep 01:24
Compare
Choose a tag to compare

Windows binary: https://github.com/leafo/moonscript/releases/tag/win32-v0.5.0

Syntax updates

Function calls

Function calls with parentheses can now have free whitespace around the
arguments. Additionally, a line break may be used in place of a comma:

my_func(
  "first arg"
  =>
    print "some func"

  "third arg", "fourth arg"
)

Function argument definitions

Just like the function all update, function argument definitions have no
whitespace restrictions between arguments, and line breaks can be used to
separate arguments:

some_func = (
  name
  type
  action="print"
) =>
  print name, type, action

Additions

  • elseif can be used part of an unless block (nymphium)
  • unless conditional expression can contain an assignment like an if statement (#251)
  • Lua 5.3 bitwise operator support (nymphium) (Kawahara Satoru)
  • Makefile is Lua version agnostic (nymphium)
  • Lint flag can be used with moonc watch mode (ChickenNuggers)
  • Lint exits with status 1 if there was a problem detected (ChickenNuggers)
  • Compiler can be used with lulpeg

Bug Fixes

  • Slice boundaries can be full expressions (#233)
  • Destructure works when used as loop variable in comprehension (#236)
  • Proper name local hoisting works for classes again (#287)
  • Quoted table key literals can now be parsed when table declaration is in single line (#286)
  • Fix an issue where else could get attached to wrong if statement (#276)
  • Loop variables will no longer overwrite variables of the same name in the same scope (egonSchiele)
  • A file being deleted will not crash polling watch mode (ChickenNuggers)
  • The compiler will not try to compile a directory ending in .moon (Gskartwii)
  • alt_getopt import works with modern version (Jon Allen)
  • Code coverage not being able to find file from chunk name

win32-v0.5.0

26 Sep 01:22
Compare
Choose a tag to compare
update to 0.5.0

v0.4.0

07 Dec 02:16
Compare
Choose a tag to compare

You can now find windows binaries through GithHub's releases. See win32-v0.4.0

Changes to super

super now looks up the parent method via the class reference, instead of a
(fixed) closure to the parent class.

Given the following code:

class MyThing extends OtherThing
  the_method: =>
    super!

In the past super would compile to something like this:

_parent_0.the_method(self)

Where _parent_0 was an internal local variable that contains a reference to
the parent class. Because the reference to parent is an internal local
variable, you could never swap out the parent unless resorting to the debug
library.

This version will compile to:

_class_0.__parent.__base.the_method(self)

Where _class_0 is an internal local variable that contains the current class (MyThing).

Another difference is that the instance method is looked up on __base instead
of the class. The old variation would trigger the metamethod for looking up on
the instance, but a class method of the same name could conflict, take
precedence, and be retuned instead. By referencing __base directly we avoid
this issue.

Super on class methods

super can now be used on class methods. It works exactly as you would expect.

class MyThing extends OtherThing
  @static_method: =>
    print super!

Calling super will compile to:

_class_0.__parent.static_method(self)

Improved scoping for super

The scoping of super is more intelligent. You can warp your methods in other
code and super will still generate correctly. For example, syntax like this
will now work as expected:

class Sub extends Base
  value: if debugging
    => super! + 100
  else
    => super! + 10

  other_value: some_decorator {
    the_func: =>
      super!
  }

super will refer to the lexically closest class declaration to find the name
of the method it should call on the parent.

Bug Fixes

  • Nested with blocks used incorrect ref (#214 by @geomaster)
  • Lua quote string literals had wrong precedence (#200 by @nonchip)
  • Returning from with block would generate two return statements (#208)
  • Including return or break in a continue wrapped block would generate invalid code (#215 #190 #183)

Other

  • Refactor transformer out into multiple files
  • moon command line script rewritten in MoonScript
  • moonscript.parse.build_grammar function for getting new instance of parser grammar
  • Chain AST updated to be simpler

win32-v0.4.0

07 Dec 01:03
Compare
Choose a tag to compare
add auth token for release

MoonScript v0.2.4

02 Jul 20:17
Compare
Choose a tag to compare

I'm happy to announce MoonScript version 0.2.4, the CoffeeScript inspired language that compiles to Lua. It's been about 5 months since the last release.

As always, if you've got any questions or want to tell me about how you are using MoonScript you can email me or contact me on twitter.

You can find the full release notes on my blog: http://leafo.net/posts/moonscript_v024.html

Changes

  • The way the subtraction operator works has changed. There was always a little confusion as to the rules regarding whitespace around it and it was recommended to always add whitespace around the operator when doing subtraction. Not anymore. Hopefully it now works how you would expect. (a-b compiles to a - b and not a(-b) anymore).
  • The moon library is no longer sets a global variable and instead returns the module. Your code should now be:
moon = require "moon"
  • Generated code will reuse local variables when appropriate. Local variables are guaranteed to not have side effects when being accessed as opposed to expressions and global variables. MoonScript will now take advantage of this and reuse those variable without creating and copying to a temporary name.
  • Reduced the creation of anonymous functions that are called immediately.
    MoonScript uses this technique to convert a series of statements into a single expression. It's inefficient because it allocates a new function object and has to do a function call. It also obfuscates stack traces. MoonScript will flatten these functions into the current scope in a lot of situations now.
  • Reduced the amount of code generated for classes. Parent class code it left out if there is no parent.

New Things

  • You can now put line breaks inside of string literals. It will be replaced with \n in the generated code.
x = "hello
world"
  • Added moonscript.base module. It's a way of including the moonscript module without automatically installing the moonloader.
  • You are free to use any whitespace around the name list in an import statement. It has the same rules as an array table, meaning you can delimit names with line breaks.
import a, b
  c, d from z
  • Added significantly better tests. Previously the testing suite would only verify that code compiled to an expected string. Now there are unit tests that execute the code as well. This will make it easier to change the generated output while still guaranteeing the semantics are the same.

Bug Fixes

  • b is not longer treated as self assign in { a : b }
  • load functions will return nil instead of throwing error, as described in documentation
  • fixed an issue with moon.mixin where it did not work as described

Other Stuff

Libraries

Some updates for libraries written in MoonScript:

  • Lapis, the MoonScript powered web framework has come out with version
    0.0.2.
  • magick, LuaJIT FFI bindings to ImageMagick
  • web_sanitize, HTML sanitization

Games

Ludum Dare happened again, and I wrote another game in MoonScript:

Thanks

Thanks to everyone who provided feedback for this release. See you next time.

MoonScript v0.2.3-2

02 Jul 20:31
Compare
Choose a tag to compare

Fixed bug with moonloader not loading anything

MoonScript v0.2.3

02 Jul 20:30
Compare
Choose a tag to compare

Today marks MoonScript version 0.2.3, the CoffeeScript inspired language that compiles to Lua. It's been about 3 months since last release. I've got a couple new features, fixes, Lua 5.2 support and a backwards incompatible change.

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_v023.html

Changes

  • For loops when used as expressions will no longer discard nil values when accumulating into an array table. This is a backwards incompatible change. Instead you should use the continue keyword to filter out iterations you don't want to keep. Read more here.
  • The moonscript module no longer sets a global value for moonscript and instead returns it. You should update your code:
moonscript = require "moonscript"

New Things

Bug Fixes

  • Numbers that start with a dot, like .03, are correctly parsed
  • Fixed typo in fold library function
  • Fix declaration hoisting inside of class body, works the same as local * now

Other Stuff

MoonScript has made its way into GitHub. .moon files should start to be recognized in the near future.

Web

I've started a couple interesting projects for MoonScript as a web programming language.

  • Lapis -- A MoonScript friendly web framework. Includes application routing, a HTML construction MoonScript DSL, and a basic ORM.
  • cloud_storage -- A MoonScript/Lua module for interacting with Google Cloud Storage.

Using the following I've created a community powered Lua rock hosting website called MoonRocks:

http://rocks.moonscript.org. (source)

Compiled MoonScript runs inside of the nginx distribution OpenResty. I created a created a Lua rock for running OpenResty on Heroku in conjunction with my Heroku Lua buildpack.

Games

Ludum Dare happened again, two games were created in
MoonScript:

Additionally, Michael F has created a game engine, BoxEngine, which natively supports MoonScript.

Thanks

Thanks to everyone who provided feedback for this release. See you next time.

MoonScript v0.2.2

02 Jul 20:34
Compare
Choose a tag to compare

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

New Things

The Language

The API

The Tools

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 of x 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.

MoonScript v0.2.0

02 Jul 20:37
Compare
Choose a tag to compare

Exactly 3 months ago I released MoonScript. The CoffeeScript inspired language that compiles to Lua. Since then I've both written a lot of MoonScript and enhanced the MoonScript compiler.

Today I'm proud to release v0.2.0. I've got a handful of new features and bug fixes.

You can find the full release notes on my blog: http://leafo.net/posts/moonscript_v020.html

Thanks for checking it out, follow me on twitter for updates or complaints.

Changes

  • , is used instead of : for delimiting table slice parts.
  • Class objects store the metatable of their instances in __base. __base is also used in inheritance when chaining metatables.

New Things

The Language

  • Added key-value table comprehensions.
  • Added a switch statement.
  • The body of a class can contain arbitrary expressions in addition to assigning properties. self in this scope refers to the class itself.
  • Class objects themselves support accessing the properties of the superclass they extend (like instances).
  • Class objects store their name as a string in the __name property.
  • Enhanced the super keyword in instance methods.
  • Bound methods can be created for an object by using object\function_name as a value. Called function stubs.
  • Added export * statement to export all assigned names following the statement.
  • Added export ^ statement to export all assigning names that begin with a capital letter following the statement.
  • export can be used before any assignment or class declaration to export just that assignment (or class declaration).
  • Argument lists can be broken up over several lines with trailing comma.
  • :hello is short hand for hello: hello inside of table literal.
  • Added ..= for string concatenation.
  • table.insert no longer used to build accumlated values in comprehensions.

The API

  • Added loadfile, loadstring, and dofile functions to moonscript module to load/run MoonScript code.
  • Added to_lua function to moonscript module to convert a MoonScript code string to Lua string.

The Tools

Standard Library

I'm now including a small set of useful functions in a single module called moon:

require "moon"

Documentation is available here.

Bug Fixes

  • Windows line endings don't break the parser.
  • Fixed issues when using ... within comprehensions when the compiled code uses an intermediate function in the output.
  • Names whose first characters happen to be a keyword don't break parser.
  • Return statement can have no arguments
  • argument names prefixed with @ in function definitions work outside of classes work with default values.
  • Fixed parse issues with the shorthand values within a with block.
  • Numerous other small fixes. See commit log.

Other Stuff

Since the first release, I've written one other project in MoonScript (other than the compiler). It's a static site generator called sitegen. It's what I now use to generate all of my project pages and this blog.