| Message |
Flannel, I don't think that there is much difference in friendliness between VB and Lua, especially in those examples:
Lua
if "%1" == "none" then
SetVariable ("target", "")
ColourNote ("white", "blue", "No current target")
else
SetVariable ("target", "%1")
ColourNote ("white", "blue", "Target is now %1")
end -- if
VB
if "%1" = "none" then
SetVariable "target", ""
ColourNote "white", "blue", "No current target"
else
SetVariable "target", "%1"
ColourNote "white", "blue", "Target is now %1"
end if
The intention in each case is pretty obvious. The main differences are:
- Lua uses "==" for equality test, rather than "=".
Personally I think it is less confusing to have two different symbols for two different operations. In VB, for example, you can write this:
b = 2
a = b = 2
Note a ' answer is -1 (true) because b = 2
a = b = 3
Note a ' answer is 0 (false) because b <> 3
Don't you think that "a = b = 2" is confusing, when the "=" symbols mean two different things in a single line?
In Lua you would have to write:
b = 2
a = b == 2
Note (a) ' answer is true because b == 2
a = b == 3
Note (a) ' answer is false because b ~= 3
It is clear there you are doing two different things, assignment and comparison.
- The other major difference is the parentheses on a function call.
Say you are debugging something like this:
In VB you must not write parentheses here, because you are not calling DoAfter as a function. But if you want to check the results, you have to put them in:
result = DoAfter (0, "go north")
Note result
However with Lua, you consistently put in the parentheses, eg.
DoAfter (0, "go north") -- use parentheses
result = DoAfter (0, "go north") -- still use them
Note (result)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|