[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Quaternary Operator
- From: Axel Kittenberger <axkibe@...>
- Date: Sun, 21 Nov 2010 00:49:22 +0100
On topic, IMHO all we might be missing is a shortcut for anonymous functions
currently it can be coded with:
-
function ifq(condition, f_true, f_false, f_nil)
if condition == nil then
return f_nil or and f_nil()
elseif condition then
return f_true and f_true()
else
return f_false and f_false()
end
end
local foo = ifq(table, function() return table.bar end, function()
return "isfalse" end, function return "isnil" end)
-
looks clumsy, but with a lexical shortcut
-
local foo = ifq(table, |table.bar|, |"isfalse"|, |"isnil"|)
-
it looks ok.
On Sat, Nov 20, 2010 at 10:52 PM, Axel Kittenberger <axkibe@gmail.com> wrote:
> didnt know the name existed, but was telling already my friends as the
> development evolves we will soon have the thousand-blade which you
> dont even have to wave over your cheek at all. You just hold it near
> your face and the hairs will spring off in fear.
>
> this will be the end of the razor industry, since they wont wear off anymore.
>
> On Sat, Nov 20, 2010 at 4:16 PM, KHMan <keinhong@gmail.com> wrote:
>> On 11/20/2010 10:52 PM, David Kastrup wrote:
>>>
>>> Nilson writes:
>>>
>>>> As today seems to be the day to talk about Lua's syntax enhancements,
>>>> I would like to talk about another one:
>>>>
>>>> "Quaternary operator"
>>>>
>>>> [<exp>; true_result; false_result; nil_result ]
>>>
>>> Anybody else having fond memories of the arithmetic goto?
>>
>> Darn it, I'm doing Quintuple! [1]
>> :-p
>>
>> [1] Google "five blades" if you don't know the meme
>>
>> --
>> Cheers,
>> Kein-Hong Man (esq.)
>> Kuala Lumpur, Malaysia
>>
>>
>>
>