Hi Zep! :)
0.2.5g: In non-C-style for loops, if a multi-line comment is opened/closed before the first variable declaration, without trailing whitespace before the variable name, it will throw a syntax error. All other situations seem to be okay:
--[[ok]]foo = --[[ok]]{1} --ok for --[[ok]]i=0,1 do print(foo[i]) end for --[[ok]] v in all(foo) do print(v) end for --[[ok]] k, --[[ok]]v in pairs(foo) do print(v) end for --[[ok]] k, --[[ok]]v in ipairs(foo) do print(v) end --not ok for --[[oops]]v in all(foo) do print(v) end for --[[oops]]k, --[[ok]]v in pairs(foo) do print(v) end for --[[oops]]k, --[[ok]]v in ipairs(foo) do print(v) end |
I wonder how vanilla lua handles these.
Edit: Well, the lua 5.3.4 that I apparently installed on this PC at some point says they're all ok.
@Felice Oops, thx, I forgot to mention I tried it on 5.4 and found it was legal. I would normally never shove comments in the middle of a line like this but Shrinko8 annotations require it
Fileinput, it appears.Generate is what FileInput is. As a result, it can only be iterated over once until all elements are eaten and executing the next method of the object raises StopIteration.
I ran into this as well (https://www.lexaloffle.com/bbs/?tid=54395)
I have a few things to add here: the first "ok" example doesn't work for me:
for --[[oops]]i=0,1 do print(i) end |
(this prints "[nil]", instead of "0 1")
And here's another interestingly-broken case:
for --[[spaaaace]]k=0,1 do print(k) end print(fork) |
This prints "[nil] 0" -- it seems that the preprocessor is accidentally removing all leading spaces before the comment, leading to the equivalent of this code:
fork=0,1 do print(k) end --nil print(fork) --0 |
[Please log in to post a comment]