Re: switch statement

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

Do I agree because C has an if statement (as do most other languages) that we should have an if statement? Sure, do you agree?

I say it's irrelevant what C has. Our objective is not to emulate or copy C, it's to make a language that is relatively easy to use for n00bs and yet has extremely powerful elements (no pun intended) that give experts lots of leeway when building programs.

If we have an if statement, it's because it's maximally functional and minimally inefficient.

Same with switch with fallthru. If we're going to have it, the positives have to outweigh the negatives. You say one of the positives is "many other languages use it that way," but consensus (or an appeal to numbers) is ultimately irrelevant when it comes to computer science. It is also easily countered with, "most instances of switch usage will use break, so break should be the default."

Anyway, in a battle of efficiency vs. tradition, efficiency always wins out in my book (unless the traditional method is the most efficient, of course smile).

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

Search



Quick Links

User menu

Not signed in.

Misc Menu