[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: metatables for strings?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 6 May 2015 22:50:42 +0200
2015-05-06 22:04 GMT+02:00 <tonyp@acm.org>:
> One I found out about today (thinking that it should work, but it didn't) is
> when you use a function returned table to define a new function in that
> table directly. Example,
>
> local t = getmetatable('')
Since some posters in this thread seem to find ("") rather
than "" annoying when indexing, it is perhaps worth while
to point out that getmetatable"" is perfectly adequate here
and later.
> function getmetatable(''):__add(s) return self..s end
I find it a great aid to readability to have a local name for
metatables. Not just "t", but "string_mt", so I cannot agree
that the above would be appealing. It looks quite ugly and
obfuscated to me, even without the superfluous ().
> One more, why not be able to do:
> ... = 1,2,3
"..." is immutable. Unilke named arguments, it belongs to
the caller's stack frame.
- References:
- metatables for strings?, Sam Putman
- Re: metatables for strings?, Nagaev Boris
- Re: metatables for strings?, Sam Putman
- Re: metatables for strings?, Sam Putman
- Re: metatables for strings?, Dirk Laurie
- Re: metatables for strings?, Nagaev Boris
- Re: metatables for strings?, Sam Putman
- Re: metatables for strings?, Nagaev Boris
- Re: metatables for strings?, Dirk Laurie
- Re: metatables for strings?, Hisham
- Re: metatables for strings?, Luiz Henrique de Figueiredo
- Re: metatables for strings?, Hisham
- Re: metatables for strings?, Soni L.
- Re: metatables for strings?, tonyp