lua-users home
lua-l archive

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


This is beautiful :-)

I've been working  for some time on and off on an almost identical
project (called Venus), but I never got around to have something
presentable.

Based on that, I have a few suggestions:

* You could adopt the YAML syntax for arrays:
  - prefixing, each
  - line, with
  - dashes.
It would provide a complete common subset between the MoonScript table
syntax and YAML.

* For function calls, allow new lines+indentation as a substitute for
comas, and an initial new line.

You_could
  call_a_function
  with_several
  long_arguments.

If you need to pass several table literals, they can be
wrapped
  ( between: parentheses
    like: this )
  ( and: this )

(Now
  (some S-expressions)
  (are also
       valid))
:D


* In tables, make the square brackets optional for string literals (I
think it is unambiguous).

* the two underscores before the init metamethod uglify the
declaration for (IMO) no good reason beside following the Lua
metamethod naming convention. If you want to keep them in the
metatable key, I'd suggest creating a special case in the class
parsing routine to detect an "init" key and prepend the underscores
automatically.

* How do you declare upvales without assigning to them? As follows? I
wish there was a nicer option (but it is not very important).

a, b = nil
z = () ->
  a=3

* a custom syntax to automatically hoist functions out of loops, to
prevent lambda creation at each iteration of the loop.

sort collection do |a,b| a > b --Ruby inspired?


Expressions as statements are great for DSLs. The table literals also
allow to prepend comments, in a way:

foo = ()->
  initialize: init!
  some_more_stuff: bang(bar)

Evil >:-D

* you can use "if expression then end" rather than assignment to _ to
turn expressions into valid statements. I think it is cheaper (but I
didn't test it, and I may be wrong)

* A combo: 1) prepend the last expression of a file with return. 2)
turn contiguous table definitions at the current level of indentation
into one table rather than several. Then you can have a file like
this:

a:b
b:c

compliled into "return {a=b,b=c}".

As far as I understand, it is compatible with the semantics of your
language, and it gives you the most beautiful configuration files in
the world.

Kind regards
-- Pierre-Yves


On Thu, Aug 11, 2011 at 08:10, leaf corcoran <leafot@gmail.com> wrote:
>
> 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
>