Writing Extensions

Bob Sneidar bobsneidar at iotecdigital.com
Thu May 25 12:21:52 EDT 2017

I agree with this. I never use the fallthrough feature because it's backwards from how I think. Trying to detemine where to put the conditions in the tree to effect the correct fall through or breaks is challenging for me. But now it is what it is. 

Bob S

> On May 24, 2017, at 03:03 , Mark Waddingham via use-livecode <use-livecode at lists.runrev.com> wrote:
> Okay so I was perhaps a little vociferous in what I said... However, fallthrough is
> the key problem - there have been numerous subtle bugs in the engine due to it
> (similarly, switch statements without 'default' can cause subtle
> bugs too - if you add a value to an enum, but don't update all the switches which
> switch on it).
> Perhaps a better model would be to use 'continue', rather than 'break':
> switch yourName
>  case "Mark"
>    -- do something and finish
>  case "John"
>    continue
>  case "Jon"
>    -- do something else
> end switch
> The idea being that 'continue' in a case, jumps to the next choice to check. This works particularly nicely when you don't have an expression, so the cases can be expressions as that essentially gives you a 'match' type construct with back-tracking (quite useful for processing hierarchical arrays and transforming them - a common operation in writing compilers, for example).
> However, it would probably be better to change the switch syntax to use different keywords (perhaps choice?). The 'switch'/'case'/'break' paradigm is so ubiquitous (due to C) that making it work differently would be very jarring.
> Warmest Regards,
> Mark.
> -- 
> Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps

More information about the use-livecode mailing list