[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: list iteration for statement
- From: "John Belmonte" <jvb@...>
- Date: Sat, 9 Jun 2001 14:03:16 +0900
I realized that a subtle issue about making this change to Lua is that it
requires the vm to know about lists. (It looks like in Sol, Edgar gets
around this by using different semantics, where a list ends at the first nil
element. This drags out the nil as false issue again.) Currently the
notion of traversing lists and the "n" field is held by the standard
library. This makes it possible to use some different convention without
changing the Lua core.
If it is acceptable for the vm to know about lists, it may be worth
considering some efficiency improvements at the same time. It seems tricky
to implement well, but the existence and correctness of the "n" field could
be an invariant managed by the vm. Currently when a literal table is
created, the list size information is not stored. Likewise when a table is
modified, the list size info is not updated. The function getn is
linear-time and furthermore may be called several times on the same table in
a normal application.
-John