[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.4.0 (work1) now available
- From: Sean Conner <sean@...>
- Date: Wed, 14 Mar 2018 14:12:44 -0400
It was thus said that the Great albertmcchan once stated:
> On Mar 14, 2018, at 5:33 PM, Gavin Wraith <gavin@wra1th.plus.com> wrote:
>
> >
> > It seems to me that the proposed syntax "x = undef" looks like
> > an assignment of a value. Why not "x undef" or "undef x"? Or have
> > I missed that discussion? Sorry for the noise if I have.
> > --
> > Gavin Wraith (gavin@wra1th.plus.com)
> > Home page: http://www.wra1th.plus.com/
> >
>
> what is so bad about the old syntax x = nil ?
>
> false were added in lua to "store" nil in table, there is no need for undef.
>
> I am curious, is there an example where undef is truly needed ?
Assume you have the following JSON:
[ 1 , 2 , true , false , nil , "alpha" , "beta" ]
Under the current (5.3) behavior, you can convert this to the following
Lua table:
{ 1 , 2 , true , false , nil , "alpha" , "beta" }
but the length is undefined, because the nil creates a hole. If you use
false instead:
{ 1 , 2 , true , false , false , "alpha" , "beta" }
the length *is* defined, but it may not have the same semantic meaning.
Now, with the proposed undef (which seems to be confusing a lot of people),
the Lua table:
{ 1 , 2 , true , false , nil , "alpha" , "beta" }
would have a defined length and semantically matches the original JSON.
-spc