[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why not allow local s = "abc":reverse()
- From: duck <duck@...>
- Date: Thu, 11 Dec 2008 21:35:00 +1100 (EST)
I assume it is because, before Lua 5.1, there was no metatable for string
objects.
This means that the method syntax couldn't be used with string objects
(only with tables and with userdata).
This means that there was never any need for the parser to deal with
syntax like:
"string":method(args)
So it didn't, and it still doesn't.
Since the notation
("string"):method(args)
is pretty clear anyway -- and can even be said to be clearer in the case
that "the string has spaces" -- then...
...IMO it's not very important to change the parser, though it might be
nice in a future non-minor update, just for the sake of completeness.
The only times I find myself particularly keen to use a method call with a
literal string is when using the string.format() function, but since that
sort of use doesn't feel like applying a method to an object anyway, I'm
happy to add the (brackets) or simplpy to write string.format()
My 3c.