lua-users home
lua-l archive

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


On Wed, Jul 3, 2013 at 11:44 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> With my JSON library it is possible to write
>>
>>   getmetatable(db.null).__tojson = function () return "null" end
>>
>> and db.null would work for the JSON encoder as well.  And in the other
>> direction you can just tell the decoder to use any arbitrary value for null.
>
> It should be clear that how to represent "null" in JSON is a problem
> quite different from how to represent "null" in Lua.
>
> If we add a new value in Lua (call it null, empty, nothing, whatever)
> to represent null in JSON, the problem with JSON is solved, because
> we do not change JSON. This change is trivial to do, but only solves
> the JSON problem.
>
> If we add a new value in Lua (call it null, empty, nothing, whatever)
> to represent null in *Lua*, the problem is not solved. Now Lua has a new
> value, and therefore we need yet another value to represent this new
> Lua value. Adding new values will not solve the problem in Lua. Period.
>
> -- Roberto
>

I'm afraid I don't understand the problem here. How is it that you'd
need a new value to describe a "null" value? It seems to me that if
it's permitted to be its own description, problem solved.

/s/ Adam