lua-users home
lua-l archive

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


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.