Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT compatible with lua 5.1 #444

Closed
badiku opened this issue Jan 4, 2023 · 3 comments
Closed

NOT compatible with lua 5.1 #444

badiku opened this issue Jan 4, 2023 · 3 comments

Comments

@badiku
Copy link

badiku commented Jan 4, 2023

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 ?

@badiku
Copy link
Author

badiku commented Jan 4, 2023

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?

@RyanSquared
Copy link
Contributor

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.

@badiku
Copy link
Author

badiku commented Jan 30, 2023

got it

@badiku badiku closed this as completed Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants