leafo/moonscript

NOT compatible with lua 5.1

badiku opened this issue · 3 comments

dead project? so many issues

just have a try,

it is said that:

it is also compatible with all existing Lua code and libraries.

so I downloaded moon binary and tried with the most simplest code:

print(_VERSION)
s = 'abcd1234'
print(s:sub(2))

but it failed.

Lua 5.1
moon: a.lua:3: (4) attempt to call global 'sub' (a nil value)
stack traceback:
a.lua:3: (4) in main chunk

obviously Lua 5.1 can run this script without any problem. and Lua 5.4

so it is NOT compatible with lua 5.1 ?

I know this works:
print(s\sub(2))

but at https://moonscript.org/ why say "compatible with all existing Lua code" ?

without mention this big difference?

MoonScript uses a completely different syntax to Lua. What it means when it says compatible with Lua 5.1, it means it can be run by the Lua 5.1 VM, can compile to code run by the Lua 5.1 VM, and can use code written for Lua 5.1 by placing it in a .lua file (where the Lua VM can then load it). Lua 5.1 code can't be embedded directly into MoonScript because they use completely different syntaxes.

got it