lua-users home
lua-l archive

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


On Jul 7, 2013, at 11:54 AM, Luis Carvalho wrote:

> Dirk Laurie wrote:
> 
>> If I am allowed to, as far as the "empty" question is concerned,
>> I can extract:
>> 
>>   Andrew thinks:
>>      - nil makes a fantastic "empty" sentinel value;
>>      - one should emphasize and increase the usefulness of nil's
>>        role as "empty," for which it is a natural fit.
>> 
>> The main thrust of Andrew's post deals with the concept of deleting
>> a value. That, I think, deserves a thread of its own.
> 
> It might. Let me just offer again the case of NA vs NULL in R, where two
> different values serve the two purposes in our discussion: missing value (NA)
> and deletion (NULL). I much prefer the lack of distinction in Lua as it
> greatly simplifies the language.

I've convinced myself that adding a value is a bad idea. Presence of a key is not very meaningful without the subject: the table. I don't see a good reason to allow this condition to be detached from its context. Creating a new value type means having to define reasonable semantics all over the place. I mentioned making it true-ish. What does empty/void do in return and argument lists? That's the one spot besides tables where an existence predicate makes sense, and it is currently a second-class mechanism there.

While I'm thinking about it: calling "delete obj.prop" has a natural meaning: remove any specialized prop from obj, and inherit from the prototype. This functionality is available (with various names) in some object systems already of course.

Jay