lua-users home
lua-l archive

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


 > I don't see why the 'update' closure is needed. Wouldn't it be more
 > straightforward to just say:
 > 
 >    ...  v, extra = f(x); assert(extra == nil) ...

I'm more paranoid than that.  f might return multiple arguments, some
of which are nil.  You'll note that even the standard library
functions do this, although not with nil in the second position.

 > Also, it's easy to allow f to return any number of values ...
 > 
 >   ...  v = { f(x) } -- save all return values
 >   ...
 >   return unpack(cache[x])

Yes, this is probably worth doing, although I'm a little reluctant to
pay the overhead of 'unpack' on the fast path when *none* of the
applications I have in mind need it.


Norman