lua-users home
lua-l archive

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


ddneilson <ddneilson@gmail.com> writes:
> I guess I just don't see how having inconsistent behaviour is desirable;
> the behaviour being defined this way doesn't make it any less
> inconsistent. function(...) pushes all of its return values onto the
> stack; but, if you call another function before popping the stack then
> you lose all but the first return value. Seems so very strange.

The current behavior is _much_ more predictable, because you can
trivially see what will happen by only looking at the call site (in the
source code).  As a result, it's also far more robust.

I think this is a good illustration of how thoughtfully Lua is designed.

Note, I do think it would be nice if there an optional way to get the
"splicing" behavior you want, for those times when you know it's the
right thing.

E.g., some sort of "@splice ..." special-form which would tell the
compiler to keep all values:

   fun1 (fun2(), @splice fun3(), @splice fun4(), fun5())

would keep only the first result of fun2, but would keep all results
from fun3, fun4, and fun5.

-Miles

-- 
It wasn't the Exxon Valdez captain's driving that caused the Alaskan oil spill.
It was yours.  [Greenpeace advertisement, New York Times, 25 February 1990]