MoonScript is a whitespace sensitive language. This means that instead of using do and end (or { and }) to delimit sections of code we use line-breaks and indentation.
Ooh, one of the things of which I am still not sure if I should love or hate Python for that. So I don't know if I should love or hate MoonScript for that either...
I am however glad about features like
Code: Select all
a = 1
a += 1
print (a) -- prints 2
as that is something I really miss in Lua. (Would a++ also work?)
I am also not sure if I am happy about auto-local inside functions.... That has a bit to do with the way Lua has been set up. Lua needs no declarations aside from locals (except maybe for tables as they require a tabvar={} command) often forcing me to "declare" globals inside functions. Now as a Pascal programmer (although my skills in Pascal are a bit outdated and rusty now), I wouldn't mind it, and there any var declared inside a function or procedure (procedures in Pascal are required when the function returns no value. A bit similar to void functions in C) is also automatically a local, but since all globals needed to be declared anyway, the trouble I see in MoonScript is automatically non-existent in Pascal. Well, I guess the same goes for Go. It's been too long ago I tried to code anything at all in C.
So I guess it has its pros and its cons. MoonScript code is in most cases definitely shorter, which can be a plus.
I think I'll stick with standard Lua, but I can see how some people might prefer MoonScript over Lua, as the cons are most of all my personal preference in this.