lua-users home
lua-l archive

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


2014-04-16 10:22 GMT+02:00 steve donovan <steve.j.donovan@gmail.com>:
> On Wed, Apr 16, 2014 at 10:12 AM, Philipp Janda <siffiejoe@gmx.net> wrote:
>> Depending on the coding style there is not that much convenience involved,
>> e.g.:
>> `s_gsub( s, "x", "y" )` vs. `s:gsub( "x", "y" )` (three more characters
>> including a space).
>
> It's what I would do _when_ I am concerned about performance.  Fact
> remains, there are string methods, and sufficiently many people like
> them to make their disappearance a great disappointment.

One easily overlooked feature is that you do not need the
debug library to add metamethods to strings. There is already
a metatable, and it isn't write protected.

Quite an attractive idea now that we have so many new metamethods.
Unfortunately string-to-number coercion creates pretty Lua examples
for Gary Bernhardt's next talk on Wat.

> "abcde"<<2
cde
> "abcde">>2
abc
>"12345"<<2
49380
"12345">>2
3086

[1] https://www.destroyallsoftware.com/talks/wat‎;