[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 09:58:20 -0600
Soni They/Them L. <fakedme@gmail.com> wrote:
> switch x do
> case math.random() do print "a" end
> case math.random() do print "b" end
> case math.random() do print "c" end
> else do print "e" end
> end
>
> -- desugars into
>
> if x == math.random() then print "a"
> elseif x == math.random() then print "b"
> elseif x == math.random() then print "c"
> else print "e" end
Okay, so we are taking about the same thing... though I still don't
necessarily see a practical use for this specific example.
With the current version of my switch/case patch providing a fallback to
using if/else for a switch construct with non-constant blocks isn't possible.
However, using my Token Storage system I could easily defer the non constant
case blocks... though the issue with fallthrough would still exist using
if/else constructs for non-constant values, which is the usual problem when
'desugaring' switch/case blocks that use fallthrough.
I suppose one fix to the issue would be to simply disallow fallthrough and
force a break for switch constructs that have non-constant case values.
Hmm, thanks for bringing this idea up, Soni. What you request may actually
be possible... I will have to tinker with some code and see what I can come
up with for non-constant case blocks! :)
~Paige
- References:
- Has Lua reached perfection?, Dibyendu Majumdar
- Re: Has Lua reached perfection?, Coda Highland
- 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.