[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string[], doesn't exist?
- From: David Given <dg@...>
- Date: Wed, 21 Jun 2006 21:59:30 +0100
Sam Roberts wrote:
[...]
> Its not clear to me what the function of this is, why this is useful.
It's because there are an awful lot of operations that you might want to apply
to strings --- string.find(), string.match(), string.gsub(), etc. By
special-casing string's metatable like that, it means you can call the
functions in the string library on a string as if it were a method. i.e.,
s:find(), s:match(), s:gsub() etc. This makes life considerably easier.
It hasn't, AFAIK, been considered worth it to do this for the other builtin
types, but I suppose it could be useful for some (such as number).
Note that for obvious reasons you can't do this for tables!
--
+- David Given --McQ-+ "Gaping from its single obling socket was
| dg@cowlark.com | scintillating, many fauceted scarlet emerald..."
| (dg@tao-group.com) | --- Jim Theis, _The Eye of Argon_ (spelling
+- www.cowlark.com --+ original)
Attachment:
signature.asc
Description: OpenPGP digital signature
- References:
- Bitwsie operators in Lua, mike krimerman
- Re: Bitwsie operators in Lua, Gavin Wraith
- Re: Bitwsie operators in Lua, Sam Roberts
- Re: Bitwsie operators in Lua, Andy Stark
- Re: Bitwsie operators in Lua, Doug Rogers
- Re: Bitwsie operators in Lua, Andy Stark
- Re: Bitwsie operators in Lua, Roberto Ierusalimschy
- string[], doesn't exist?, Sam Roberts
- Re: string[], doesn't exist?, Luiz Henrique de Figueiredo
- Re: string[], doesn't exist?, Sam Roberts