Writing Extensions

Kay C Lan lan.kc.macmail at gmail.com
Wed May 24 10:19:06 CEST 2017


On Wed, May 24, 2017 at 2:49 AM, Mark Waddingham via use-livecode
<use-livecode at lists.runrev.com> wrote:
> On 2017-05-23 18:02, Mark Wieder via use-livecode wrote:
>
> In regards to 'switch' - 'switch' in LiveCode copied the C 'switch' which
> is pretty much universally considered to be one of the worst designs of
> such a thing and we didn't want to repeat that 'mistake'.
>
I apologise for straying off topic but as one who found HyperCard to
be a revelation, and then stumbled across Switch in Revolution and was
just blown away (I'm pretty sure HC didn't have Switch) and now use it
EVERY time I script I was wondering if you'd be kind enough to
elaborate on what's wrong with LCs Switch.

I tried to google 'faults with C implementation of switch statement'
and other similar searches but didn't find any smoking gun:

https://www.codeproject.com/Articles/100473/Something-You-May-Not-Know-About-the-Switch-Statem

https://softwareengineering.stackexchange.com/questions/162615/why-dont-languages-use-explicit-fall-through-on-switch-statements

In that last one the only inference I could find was that due to the
probability that in 97% of use 'fall through' is not intended, a whole
heap of typing could be saved if no keyword (break) was required for
the 97%, and a keyword was only used to activate fall through. i.e.

switch yourName
case "Mark"
  -- do something
break
case "John"
case "Jon"
  -- do somethingElse
break
case "Ali"
  -- do anotherThing
break
end switch

would become

switch yourName
case "Mark"
  -- do something
case "John"
   fall --or some other keyword
case "Jon"
  -- do somethingElse
case "Ali"
  -- do anotherThing
end switch


11 less character to write. Is this the only problem with the current
implementation of Switch?



More information about the use-livecode mailing list