From: Arlen Christian Mart Cuss Date: 2007-10-21T19:50:07+09:00 Subject: Re: Is it always the norm to skip 'return'? Hi, On Sat, 2007-10-20 at 18:56 +0900, Alex Young wrote: > "AV Rule 113 (MISRA Rule 82, Revised) > Functions will have a single exit point. > Rationale: Numerous exit points tend to produce functions that are both > difficult to understand and analyze. > Exception: A single exit is not required if such a structure would > obscure or otherwise significantly complicate (such as the introduction > of additional variables) a function’s control logic. Note that the usual > resource clean-up must be managed at all exit points." I think we're both in agreement and not. Particularly, the exception - if it would obscure/complicate the control logic. Typical C++ programming tendencies, however, should make the matter of resource releasing a non-issue; objects are typically passed in by reference (cleanup takes place lower in the stack) or are instantiated in the function itself (and are automatically destructed on function exit/exception conditions). Some people tend to use pointers and new/delete for everything, and that's when you get issues with exit points like this. > It's less of a problem in Ruby, I think, mainly because of the > expressiveness and the presence of GC. Still, I think you're right about it being a lesser problem in Ruby, and in the end it may just come down to style, yet again. Readable code is achievable both ways, I believe, but it may be more effort in some cases with several exit points. Arlen