moonscript/CHANGELOG.md
leaf corcoran de0717027d fix typo
2014-06-19 00:41:59 -07:00

13 KiB

MoonScript v0.2.6 (2014-6-18)

Bug Fixes

  • Fixes to posmap generation for multi-line mappings and variable declarations
  • Prefix file name with @ when loading code so stack traces tread it as file
  • Fix bug where moonc couldn't work with absolute paths
  • Improve target file path generation for moonc

MoonScript v0.2.5 (2014-3-5)

New Things

  • New code coverage tool built into moonc
  • New linting tool built into moonc, identifies global variable references that don't pass whitelist
  • Numbers can have LL and ULL suffixes for LuaJIT

Bug Fixes

  • Error messages from moonc are written to standard error
  • Moonloader correctly throws error when moon file can't be parsed, instead of skipping the module
  • Line number rewriting is no longer incorrectly offset due to multiline strings

Code Generation

Bound functions will avoid creating an anonymous function unless necessary.

x = hello\world

Before:

local x = (function()
  local _base_0 = hello
  local _fn_0 = _base_0.world
  return function(...)
    return _fn_0(_base_0, ...)
  end
end)()

After:

local x
do
  local _base_0 = hello
  local _fn_0 = _base_0.world
  x = function(...)
    return _fn_0(_base_0, ...)
  end
end

Explicit return statement now avoids creating anonymous function for statements where return can be cascaded into the body.

->
  if test1
    return [x for x in *y]

  if test2
    return if true
      "yes"
    else
      "no"

  false

Before:

local _
_ = function()
  if test1 then
    return (function()
      local _accum_0 = { }
      local _len_0 = 1
      local _list_0 = y
      for _index_0 = 1, #_list_0 do
        local x = _list_0[_index_0]
        _accum_0[_len_0] = x
        _len_0 = _len_0 + 1
      end
      return _accum_0
    end)()
  end
  if test2 then
    return (function()
      if true then
        return "yes"
      else
        return "no"
      end
    end)()
  end
  return false
end

After:

local _
_ = function()
  if test1 then
    local _accum_0 = { }
    local _len_0 = 1
    local _list_0 = y
    for _index_0 = 1, #_list_0 do
      local x = _list_0[_index_0]
      _accum_0[_len_0] = x
      _len_0 = _len_0 + 1
    end
    return _accum_0
  end
  if test2 then
    if true then
      return "yes"
    else
      return "no"
    end
  end
  return false
end

MoonScript v0.2.4 (2013-07-02)

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

MoonScript v0.2.3-2 (2013-01-29)

Fixed bug with moonloader not loading anything

MoonScript v0.2.3 (2013-01-24)

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.

MoonScript v0.2.2 (2012-11-03)

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.

MoonScript v0.2.0 (2011-12-12)

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.

MoonScript 0.1.0 (2011-08-12)

Initial release