lua-users home
lua-l archive

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

On Thursday 04 November 2004 3:25 pm, Mike Pall wrote:
>     t[] = o    -- equivalent to t[nil] = o which is currently invalid
>      Having a t[] lvalue it's obviously tempting to define semantics for
>      a t[] rvalue, too. And in fact it's quite orthogonal to define
>      __index(t, nil) to return the length (and not nil):
>        n = t[]
> - The reuse of __index and __newindex has nice implications for
>   orthogonality when it comes to generic container types built upon
>   tables or userdata:

I really like this syntax.  it feels much better than * or even #
specially because it's just syntactic sugar, and only defines new 
functionality on t[nil]

also suggested is a full slice syntax.  it's certainly one of the things i 
like about other scripting languages, (pike? i forgot); but it assumes an 
ordered sequence, something that hash tables just are not.

i'd like to have b-trees in addition to hash tables (a nice midpoint between 
arrays and hashes); but that could be managed with userdata objects, not as a 
first order type.


Attachment: pgpjbr44yqcWH.pgp
Description: PGP signature