Re: New switch/case idea

new topic     » goto parent     » topic index » view thread      » older message » newer message
DanM said...
kinz said...

The more I read about switch, select, break, continue, do, then etc, the more I'd like to see just something like to old good simplest basic's "on X goto", namely EU version:

on X 
    case 1 
        ? 1  
    case 2, 3, 4, "John" 
        ? 2  
end on 

I happen to agree with Igor on using on X instead of "switch", although I would "re-complicate" it by allowing the "with fallthrough" & break and continue and maybe the "then". I think anyone, whether used to the idea/name "switch" or not would understand it immediatly.

This would also maybe remove the concern that programmers from other languages who expect fallthrough to be the default might be confused if not fallthrough is the default, since the word "switch" would not be there to engender any confusion re past expectations.

Dan

Ok, but EU is case-sensitive, so we can have up to 4 options - "on X", "On X", "oN X", "ON X" just to avoid all these "with fallthrough" etc and describe the sense of options in documentation.

Same for export/public etc. Say, new "public" is old "export", but new "Public" is old "public". Also for export/public/global we can use just single "visible_N", where N may be from 1 to the maximum deep of includeing, or "includable_N", or just "up_N".

Same about "case", say, "Case" = "case ... break".

Anyway you'll need the careful learning of docs to use these complicated features.

So, the basic option must be the simplest one:

on X 
   case 1 Do(1)  -- then exit on .. end on immediatelly 
   case 2 DO(2)  -- then exit on .. end on immediatelly 
   case 3 dO(3)  -- then exit on .. end on immediatelly 
   else Do_Do()  -- then exit on .. end on - it just ends anyway 
end on 

But if someone needs break, fallthrough etc, he/she has to read docs and then use On X, or oN X, or ON X.

Just my anti-crisis $0.005 smile

Regards,
Igor Kachan
kinz@peterlink.ru

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu