[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Has Lua reached perfection?
- From: Paige DePol <lual@...>
- Date: Sun, 28 Jan 2018 11:19:07 -0600
Soni They/Them L. <fakedme@gmail.com> wrote:
> On 2018-01-28 01:58 PM, Paige DePol wrote:
>> However, in a switch/case with a mix of constant and non-constant case blocks
>> the constant ones would be checked first via lookup table, and if that failed
>> then the non-constant blocks would be checked via if/else, and if all blocks
>> failed the 'else' block would be executed.
>
> But what if a non-constant case comes first, and the constant case has the
> same value? Shouldn't the non-constant case run, rather than the constant
> case? I think it should.
Mixing constant and non-constant values in a switch block is always going to
have some trade offs. In the case where there would be conflict like you've
mentioned it would then be up to the coder to use the most relevant construct.
If I were to allow constant and non-constant values in case blocks, which
after all this discussion I am not even sure is a good idea, I would say
the constant value lookup would be done followed by the if/else construct
for non-constant values. Thus the constant values would have priority.
Otherwise, for the example you gave... just use if/else in the first place,
or only use non-constant or non-conflicting values as case values?
~Paige
- References:
- Has Lua reached perfection?, Dibyendu Majumdar
- Re: Has Lua reached perfection?, KHMan
- Re: Has Lua reached perfection?, Paige DePol
- Re: Has Lua reached perfection?, KHMan
- Re: Has Lua reached perfection?, Sean Conner
- Re: Has Lua reached perfection?, KHMan
- Re: Has Lua reached perfection?, Dirk Laurie
- Re: Has Lua reached perfection?, Paige DePol
- Re: Has Lua reached perfection?, Soni "They/Them" L.
- Re: Has Lua reached perfection?, Paige DePol
- Re: Has Lua reached perfection?, Soni "They/Them" L.
- Re: Has Lua reached perfection?, Paige DePol
- Re: Has Lua reached perfection?, Soni "They/Them" L.
- Re: Has Lua reached perfection?, Paige DePol
- Re: Has Lua reached perfection?, Soni "They/Them" L.
- Re: Has Lua reached perfection?, Paige DePol
- Re: Has Lua reached perfection?, Soni "They/Them" L.
- Re: Has Lua reached perfection?, Paige DePol
- Re: Has Lua reached perfection?, Soni "They/Them" L.