lua-users home
lua-l archive

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


On Feb 28, 2013, at 22:37, Coda Highland <chighland@gmail.com> wrote:

> On Thu, Feb 28, 2013 at 8:20 PM, Javier Guerra Giraldez
> <javier@guerrag.com> wrote:
>> On Thu, Feb 28, 2013 at 6:47 PM, Sven Olsen <sven2718@gmail.com> wrote:
>>> By chaining ~, I can write statements like the following, which are safe
>>> even when 'object' or any of it's subtables have a chance of being nil:
>>>
>>>  color = object~icon~glow~color or white
>>
>> you can change the metatable of nil to get that behavior.
>>
>>
>> --
>> Javier
>
> You could also use a unique userdata and assign a metatable to that.
>
> /s/ Adam
>

I've dreamed of an "?" operator. I type endless variations of:

V == nil
type(V) == "table" and v.m ~= nil and v.m
Etc

I think a general "exists?" operator would be welcomed, by me at
least. I get that == nil does the same thing but claiming that
anything can be "equal to nil" seems uncomfortable to me.

I really like this in conjunction with field specifiers.

But I want everything all of the time. I feel so... American.

-Andrew Starks

"As we get older, and stop making sense"
-David Byrne