lua-users home
lua-l archive

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


Zero isn't falsey, why should NaN be? If you want to, you can do explicit checking for both. Many idioms - such as the a = a or b assingment - would break, because they are used for initializing an unassigned variable to a safe default. Also, NaNs should propagte until explicitly stopped, so it should definitely not be implicitly false.

On Sun, Jul 24, 2016 at 10:48 PM, Soni L. <fakedme@gmail.com> wrote:


On 24/07/16 05:45 PM, Gregg Reynolds wrote:

On Jul 24, 2016 3:27 PM, "Sean Conner" <sean@conman.org <mailto:sean@conman.org>> wrote:
>
> It was thus said that the Great Roberto Ierusalimschy once stated:
> > > I agree with Jorge. Also, sometimes when returning multiple things,
> > > one of these things might be nil, so it's not only the error situation
> > > that produces a nil value upon return, although it is of course the
> > > most common. So, unfortunately just changing the policy from
> > > nil-on-error to false-on-error still wouldn't allow us to just forget
> > > about table.pack().
> >
> > 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).
>
>   _javascript_ has an "undefined" state, in addition to a "null" state.
> Perhaps Lua should have one as well.  To me, "nil" means "the absence of a
> value" while "undef" means "this never had a value to begin with".
>
howsabout NaV (Not a Value) by analogy to NaN?  "Undefined value" seems kind of an oxymoron to me.  NaV could mean sth like "its a value, kinda sorta, but one that cannot be represented, not even by nil".

Well JSON can't store NaNs so you could repurpose NaNs for null.

Only wish NaNs were falsey...

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.