lua-users home
lua-l archive

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


on 4/3/06 11:55 AM, Dolan, Ryanne Thomas (UMR-Student) at rtdmr6@umr.edu
wrote:

>   for i = 1, select ('#', ...) do
>       assert (type (select (i, ...)) == "table",
>           "invalid base class specified");
> 
>       for k, v in pairs (select (i, ...)) do
>           c [k] = v;
>       end;
>   end;

A plea for more syntactic sugar/VM enhancements. (Unfortunately, the VM
enhancements would probably break existing byte-code.)

1. #... should be the same as select( '#', ... ) but should be able to avoid
copying the values around.

2. ...[ j ] should be the same as ( select( j, ... ) ) but again bypassing
the need to copy values around.

Or at the very least, the Lua library needs a standard function to generate
an iterator from a series of values so that one could write:

    for i, arg in varargs( ... ) do
        -- code goes here
    end

(It doesn't really need to be named "varargs" since one also ought to be
able to write things like varargs( "red", "green", "blue" ). I just wasn't
feeling creative about a name.)

Mark