[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: getn
- From: "John Belmonte" <jvb@...>
- Date: Sat, 25 Aug 2001 13:27:31 +0900
> BTW, I think I figured out why there's resistance to adding
> the "fori" syntax. Base Lua has no concept of lists/vectors
> at all; everything that treats tables this way is in liblualib.a,
> not liblua.a.
This is not entirely true. The VM deals with lists for the vararg stuff.
It doesn't know how to compute n for an arbitrary table however.
> If there was a way to set a tag method for iteration, I would be
> happy with that, or perhaps a for syntax that allowed a
> user-specified iterator function in some non-ugly way.
> (for i,v in t in numeric_order, where numeric_order is a global
> function that gives me 1,2,3,4..getn behavior.)
See http://python.sourceforge.net/peps/pep-0234.html for some ideas.