Re: New switch/case idea

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...
DerekParnell said...

I think that if you do some analysis you will find that the majority of switch usage is non fall through, so we have made that the default setting and this will mean less typing to do.

Jeremy argued at one point that switch with fallthru as default was the norm for many other languages. I wonder then, if we're to introduce and welcome those programmers into the Euphoria community, we shouldn't have fallthru be the default, to keep things somewhat similar to them and lessen the learning curve a bit. Yes, I voted for "without fallthru" as default, but I'm having voter's remorse. I think the option "without fallthru" will satiate the dissenters who don't want fallthru as default.

Just throwing that out there for consideration. I don't care one way or the other. smile

I voted for "without fallthru" as the default.

While it makes sense to borrow ideas from other languages when they are suitable, not every concept from every language is suitable for use with euphoria.

The concept of a default fall thru is one of these imvho.

http://www.rinkworks.com/stupid/cs_programming.shtml [quote="http://www.rinkworks.com/stupid/cs_programming.shtml"] Days ago I had to fix a bug into our software. The person that originally wrote the module quit, so I had total control of the source code. I totally rewrote half of the code when I found things like:

int i; memset(&i, 0, sizeof(int));

And:

switch (k) { case 9: printf("9\n"); case 8: if (k==8) printf("8\n"); case 7: if (k==7) printf("7\n"); and so on... }

I wondered why he put the "if" clauses, but then I noticed that none of the cases has its "break" statement, so if he found that if k was 9, the program printed 9, 8, 7, etc. So I think he added the "if" clauses to fix that behavior. [/quote]

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

Search



Quick Links

User menu

Not signed in.

Misc Menu