On Wed, May 24, 2017 at 8:25 PM, Mark Waddingham via use-livecode
<use-livecode@lists.runrev.com> wrote:
>
Thanks Mark for the explanation.

>   choose tValue
>     when 1
>     when 2
>     when 3
>       -- executes if tValue is 1, 2 or 3
>       -- never falls through
>
>     when 4
>       -- never falls through
>
>     default
>   end choose
>
> This caters for both cases (1) and (2) and is unambiguous.
>
Whilst I certainly like the above and think it an improvement, if I
were to 'step back' and redesign Switch I think I'd make it clearer
that 'fall through' is just an OR - it took me ages to realise and
I've have very very long: case ((....) OR (....) OR (....) ....) which
were extremely long and very hard to read until I rewrote them as

case
case
case
case
---do something
break

What I can't currently solve is the many case ((.....) AND (,,,,) AND
(....) AND (...)... )

So, again if I were reinventing Switch:

choose tVale
  when 1
  or 2
  or 3
    --do something
    -- no further fall through
  when > 6
  and < 60
  and even
    --do something else
    --no further fall through
  when 4
    --do another thing
  default
    --some other thing
end choose

Just makes it clear that fall through is being used to combine the
statements, but in my design it isn't just restricted to OR.

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to