lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2011/8/11 leaf corcoran <leafot@gmail.com>:
> Hello,
>
> I've been working on a little language heavily inspired by
> CoffeeScript, which I've called MoonScript. The homepage is located at
> http://moonscript.org
>
> It compiles into Lua, but there are numerous ways to actually run the code.
>
> The parser is all done in LPeg, and the majority of the compiler
> itself is written in MoonScript. I've also used a few other libraries
> (listed on the site) to build the tools.
>
> I've also written copious amounts of documentation in the hopes that
> someone will actually use it, http://moonscript.org/reference
>
> The source is located on GitHub: https://github.com/leafo/moonscript
>
> I've successfully installed it with LuaRocks on both Linux and OSX. I
> have not tried it on Windows, but I don't see why it wouldn't work.
>
> I think there's some pretty cool stuff in it. By just requiring
> "moonscript", you can make the require function MoonScript aware and
> have it automatically build and run .moon files as you would with .lua
> files. I've also got line number reversal, so errors that happen in
> the compiled Lua are rewritten to point back to the original
> MoonScript line.
>
> Anyway, check it out the docs to see the rest of the features. I'd
> appreciate any input (including feature requests). This is the initial
> release so there might be some bumps.
>
> Thanks, Leaf
>
>

Some advice about a short try of moon:
class array
    new: (...) =>
        return {...}
    __tostring: =>
        return '[' .. table.concat([tostring(i) for i in *self], ", ") .. ']'
    each: (fn, ...) =>
        return [fn(v, ...) for v in *self]

a = array(1, 2, 3)
print(a)
-- cc: cc='moonc'

1) new function's return value is ignored, maybe it can be used as a
new value for class. now the __init function is:

    __call = function(mt, ...)
      local self = setmetatable({}, _base_0)
      self = mt.__init(self, ...) or self
      return self
    end


maybe it can be:
    __call = function(mt, ...)
      local self = setmetatable(mt.__new(mt, ...) or {}, _base_0)
      mt.__init(self, ...)
      return self
    end

and add a new "new" function (named init? or other wise) in class.

2) you must write:
   new: (...) =>

and
  new(...) =>

is a compile error, may be allow this as a syntax sugar for moon is better:
a =
    foo(...) =>
        return \bar, ...
    bar: 123

3) now
print(1,2,3)
works well, but:
print (1,2,3) -- notice the space after print!
turns out a compile error :( why?