[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: orif
- From: Andrew Starks <andrew.starks@...>
- Date: Fri, 14 Aug 2015 13:48:18 -0500
On Fri, Aug 14, 2015 at 1:31 PM, Coda Highland <chighland@gmail.com> wrote:
> On Fri, Aug 14, 2015 at 11:29 AM, <tobias@justdreams.de> wrote:
>>
>> Quoting "Soni L." <fakedme@gmail.com>:
>>
>>>
>>> With orif:
>>>
>>> ```lua
>>> local flag = false
>>> if i == 1 then
>>> flag = true
>>> orif i == 2 then -- explicit fallthrough
>>> print(flag)
>>> else -- default
>>> print "Unknown!"
>>> end
>>> ```
>>
>>
>> Lua has elseif which is I think exactly the same:
>> local flag = false
>> if i == 1 then
>> flag = true
>> elseif i == 2 then -- explicit fallthrough
>> print(flag)
>> else -- default
>> print "Unknown!"
>> end
>>
>> Regards,
>> Tobias
>
> No, elseif is totally different semantics, and elseif is exactly WHY I
> think orif is a bad idea: elseif only fires if an earlier condition
> wasn't true. orif looks syntactically like it ought to behave like
> elseif, but it doesn't.
>
> /s/ Adam
>
Points + AND - for being clever, though. This is one of the times when
I *feel* like I'm inefficient in lua:
local the_type = type(foo)
if the_type == 'table' then
--- something
elseif type == 'number' then
--- blah
---
or some other/better example. I don't know if it *is* slow, however.
I'm not qualified to judge `orif` innovative or otherwise, but given
the volume of Sonic's proposals, I was surprised to find myself
intrigued by this one. FWIW
-Andrew