lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all!
I recall now that another tricky point for me, at first, was this:

I can do this:

local s = "hello!"
print( s:rep(10) )

but not this:

print( "hello!":rep(10) )

since it has to be written with a pair of extra parentheses:

print( ("hello!"):rep(10) )

When I type fast or refactor my code sometimes it bites me again!

Out of curiosity:

I've seen sometimes other people complaining about this behaviour now and then, but I don't remember to have seen an explanation of the reason why is it still that way.

Would changing the behaviour of Lua in this respect be so difficult? Would it lead to ambiguity in the grammar that cannot be easily solved?

thanks for any explanation!

--
Lorenzo