From: dblack@... Date: 2006-12-12T23:21:49+09:00 Subject: Re: Bug in Ruby or Pickaxe? Hi -- On Tue, 12 Dec 2006, Dave Thomas wrote: > > On Dec 12, 2006, at 4:10 AM, Robert Klemme wrote: > >> I have low expectations with regard to the "else" clause but the book >> clearly states that it is executed if there was no exception - that >> includes the case where the block is left via a "return". Behavior and >> description simply are not in sync, that's my point. > > > Interesting: I'd honestly never have thought of that interpretation. I guess > in my mind, the semantics of return take precedence over most other > semantics, and I explicitly note the times where that's not the case. Thanks > for pointing out an alternative. > > Do you feel I should also document the other places when a return could be > issued? For example, in the description of a while loop, I say "executes body > zero or more times as long as boolean-expression is true." Should I add "or > a return is executed or an exception is thrown" to this and similar > descriptions? > > I kind of feel that this would clutter the descriptions, and that most > readers would make the assumption that return and exceptions would break the > flow. Is that an incorrect assumption? No, I think it's correct. I consider "executes body" to expand automatically to "executes body unless execution is stopped, which can always happen in various ways no matter what else is going on". I think the reason the question arose in the particular case of begin/rescue/else/ensure... is that it involves the role of what to me is a somewhat elusive clause (the else) right in the middle of a construct where the control flow is already relatively complex. David -- Q. What's a good holiday present for the serious Rails developer? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) aka The Ruby book for Rails developers! Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)