lua-users home
lua-l archive

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


> On Jul 24, 2016, at 11:34 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> 
> Of course any function can return nil among its returns, but maybe
> that might be considered a bad practice.
> 
> My point is that, if nil is representing the absence of a value, it
> is weird not to have a third value but to have a fourth one. If nil
> is representing something else, probably it shouldn't be (as pointed
> out by others already).
> 
> ("is weird" ~ "it might be considered weird”)


It’s weird *only* if the values are a strict list. If the values are (conceptually) a tuple, then of course an intermediate may be nil. While it could be argued that tuples should be returned as tables, you have the same problem; you can’t put a nil mid-way (and, as others have noted, returning a tuple directly can be faster and has less memory churn).

—Tim