[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.0 (alpha) comments
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 18 Sep 2002 09:38:43 -0300
> There is a mistake in the manual on page 22.
Yes, thanks.
> There are still a few undocumented features like __tostring, __metatable,
> and table.concat which should be advertised more.
Unfortunately, there are many undocumented features yet :-(
> I find newproxy a curious addition. It gives you unique userdata that
> share the same metatable. I cannot think of a use for it yet.
> What did you have in mind?
This is a very experimental feature. We wanted a simple and secure way
of creating userdata in Lua. It has several uses, such as to monitor
garbage collection, as a light "unique" object, and for testing ;-).
But we cannot allow Lua to change the metatable of those userdata;
otherwise, Lua could break other libraries (e.g. give one of these
userdata as a file to be closed). To allow each userdata to have its own
new metatable or to share the metatable of another such userdata seems
flexible and secure.
> I like pairs and ipairs, (especially now that table.getn(t) is extra
> verbose), but ipairs can fool you if you put nil in the middle of your
> table.
Note that the new "table.getn" will also fool you in this case. If
you really need nils in the array (instead of false), you must use
table.setn and then table.getn.
-- Roberto