in reply to Re: Re: Eek! goto?
in thread Eek! goto?
I choose the switch construct BECAUSE I can have multiple values that should map to a block of code
Other languages implement that by means other than fallthrough. If you were familiar with the way Inform (or even BASIC) does this, you would understand. Here is an oversimplified short example...
Object fireplace "fireplace" livingroom with name 'fireplace' 'fire' 'place', ! Really I would use a stock idiom parse_name ! routine to only accept fire as a modifier for ! place, but for the sake of this example we'll ! simplify. before [; Receive: if (self has lit) { switch (noun) { water_baloon: "The baloon pops, and the fire hisses and crackles, but the blaze continues."; deed, certificate: remove noun; "The paper darkens, curls, and finally is consumed. I hope you don't need ", (The) noun, " any more."; ! Cases for other objects here... default: remove noun; print_ret (The) noun, " bursts into flame."; } } else { rfalse; } ! Rules for other actions here... ], ! other properties here... has scenery;
Comma-separated lists are just one way to allow multiple values. BASIC has case conditions like IS < and IS >. If Perl had switch/case, I would expect it to allow a wide variety of syntax for complete flexibility, so that for example you could switch on a variable that contains a reference, and have one case for any object that inherits from a particular class, for example, or a case for any number evenly divisible by two. Because stuff in Perl is flexible like that. With sufficient flexibility, the only reason you would ever want fallthrough would be if you wanted multiple cases to apply (potentially) in the same case, in which case the switch/case statement isn't really what you want, but a series of conditionals.
"Language X sucks" is a little harsh.
It is harsh, but it is a harsh reality that thirty-year-old problems which should have been resolved once and for all fifteen years ago (such as memory leaks and segmentation faults and buffer overruns) are still being found (and constantly) in production code of all sorts, precisely because the code is written in languages that don't protect the programmer from such basic and easy-to-make mistakes. The continued widespread use of such languages is absolutely throttling progress.
Yes, of course, at some point a lowlevel language (whether C, assembly, or whatever) has to be used to implement the basic building blocks upon which everything else is built, but I am firmly of the belief that way too much stuff is written in those lowlevel languages that does not need to be.
--jonadab
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Eek! goto?
by Helter (Chaplain) on Feb 12, 2003 at 18:16 UTC |