
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
Hallo Patrick, wie gesagt, handelt es sich bei dem Programmsegment nur um ein Beispiel. Select..Case sieht zwar in diesem Fall eleganter aus, aber funktioniert nur, wenn immer dieselbe Variable abgefragt wird. Insofern ist Dein Verweis auf Select..Case nicht ganz fair. Ich halte es nach wie vor für notwendig, ein einzeiliges IF zu unterstützen. Und zwar einfach deshalb, weil die Anwender so etwas erwarten. Schließlich existiert dieser Befehl in jedem anderen BASIC-Dialekt und im übrigen auch in vielen anderen Sprachen, eine davon ist C. Willst Du die Anwender erziehen? Auch Deine Abneigung gegen GOTOs verstehe ich nicht. Schließlich benutzt Du die selber. Die Befehle "Exit Do", "Return", continue, break, etc. sind nichts anderes als versteckte GOTOs, die ein Programm sogar noch unübersichtlicher machen können, denn hier fehlen die Labels, zu denen gesprungen wird. Solche Sprungziele ließen sich mit sinnvollen Namen benennen. Vielleicht versöhnt uns der folgende ideologiefreie Kommentar, den ich im Internet gefunden habe: Here's a good rule of thumb: don't use backward GoTo statements. Notice that continue, break, and mid-function return statements are all forward gotos (and switch is a computed forward goto). Dijkstra's argument does not apply to them. I have noticed subjectively that they aren't confusing, unless you jump into something else (like the middle of a loop). I don't think there's anything wrong with using goto to do, for example, a double break. Forward gotos are also useful for jumping to cleanup code after an error - they're often much more readable than doing your real work inside an if statement, and they're always more readable than doing your real work in a terraced landscape of nested if statements. Gruß, Dietmar Meine Homepage: http://ccintern.dharlos.de |
| Antwort schreiben |