Quote:
Originally Posted by hobnail
Gotta watch out for those dangerous returns.
|
The problem is more subtle.
1) The section MUST be in a separate function or procedure
2) Fails if copied and pasted into bigger piece of code, the Case, Select or nested ifs do not.
3) You might want the same thing related to that piece of code done after each option. The version with returns incorrectly separates it to where it's called.
4) A call and return may be slower and use more stack. Depends on language and CPU. The Case, Select or nested ifs may translate to skips or short jumps or a jump table.
As a general principle there should only be a return before the last statement in a procedure/function that's return if it's a special error trap.