What exactly would happen if I ran code with ambiguous syntax?
This is the reason for my asking.
If you take a look at the link provided by MessorAdmin in the comments
http://wiki.roblox.com/index.php/Lua_errors
You will notice that the wiki explains how Lua reads the syntax of code.
For example,
y = 1 + 3
Is the same as:
y=1+3
This is because Lua reads code almost as if it was all in a single line, with the exception of when Lua notices a ;
because that indicates a statement/link break.
Let's take a look at the replication I was able to do:
function func() return function(...) print(table.concat({...},",")) end end func() (a="hey",b="steve")
Now, the returned function inside func is expecting parameters so that it can print a concatenation of all the values inside the tuple given. Now, I might actually want to call func
with no parameters whatsoever, and just set variables a to hey
and b to steve
.
Now, if we take whitespace into account, Lua is actually interpreting the code segment as:
function()(a="hey",b="steve")
So in this case, Lua is not sure if you are trying to make a new line segment or if you're passing in Parameters into the returned function from func()
The Lua programming language uses a freeform syntax. This means that whitespace characters, such as space, tab characters and newline characters can be inserted into the program code for the purpose of spacing, alignment or indentation in either the horizontal or vertical directions.
http://en.wikibooks.org/wiki/Lua_Programming/whitespace http://wiki.roblox.com/index.php?title=Lua_errors#Ambiguous_Syntax_Errors http://en.wikipedia.org/wiki/Free-form_language
A great write up by BlueTaslem here:
https://scriptinghelpers.org/questions/16925/how-do-i-use-this-symbol
It's an error -- it won't let you run.
If it did run, it just might not mean what you think it means. It might be what you expect, though (that's what "ambiguous" means -- it could be interpreted multiple ways)
See this question for what causes this (a semicolon, or fewer parenthesis, fixes this).
Locked by FearMeIAmLag
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?