lua-users home
lua-l archive

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


Mike Pall wrote:
Hi,

Mark Hamburg wrote:

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


This already has a syntactic meaning (not that it would be missed
much). But special casing #... lowers the language consistency.

I'm having real trouble understanding what select() does. What do the two expressions above do and what is the difference between the two?

...
This one needs to allocate and GC a heap object _and_ copy the
values around. Copying a handful of values around (even
repeatedly) may or may not be more efficient.


(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.)


apairs() -- argument pairs.

Would be useful even for non-vararg cases. I'd like to have this
as standard given that the implementation takes only a few lines
(but it would be limited to 255 elements or needs to defer to
table or coroutine storage).

What happens today if you just go pairs(...)??? Again, forgive my lack of understanding of varargs and select. The manual doesn't explain this well enough, IMHO...

--
chris marrin                ,""$,
chris@marrin.com          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'