lua-users home
lua-l archive

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


On 21 March 2018 at 13:06, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> Many thanks for the examples. All of them actually would raise errors in
> my little experiment, but let us see them in the discussion about nils
> in tables.

I hope this shows how easy it is to find examples of the construct I
was talking about. :)

> In the examples from Hisham, I could not figure out whether we should see
> the nils as actual values or "instructions" to not add something.
> For instance, in the case of
>
>   entity[k] = default_value(field)
>
> does a nil mean no default or a nil as the default? Would it make any
> difference to the program if the nil was added to the table?

In both cases it is an instruction to not add something. In
default_value(), because we have to interact with the outside world
(converting to and from JSON), when the default is "null" we return it
as ngx.null.

And I hope this shows how non-trivial it is to audit working codebases
regarding their usage of nil. :)

-- Hisham