On Jul 30, 2009, at 2:16 PM, David A. Black wrote:
> Hi --
>
> On Fri, 31 Jul 2009, Lloyd Linklater wrote:
>
>> I have the answer.  fyi, it is that
>>
>> doSomething until condition
>>
>> does not work at all like
>>
>> begin doSomething end until condition
>>
>> In the first case, the condition is checked BEFORE the doSomething is
>> run.  In the second case, the condition is checked AFTER the  
>> doSomething
>> is run.  I am not sure just why this is or how I could have figured  
>> it
>> out intuitively.  It seems to me that it would be better to have
>> something like this (to mimic pascal)
>
> You didn't have to figure it out intuitively; I told you on Saturday
> :-) (Though I garbled my example a bit.)
>
>> doSomething while condition #check condition before
>>
>> doSomething until condition #check condition after
>
> I suspect Ruby got the idiom from Perl, and/or from the way similar
> language would be used in English. I'm not sure about the above in
> Pascal (a quick look at several sources doesn't show either of those
> constructs), but I don't think you'd want the while/until difference
> to make the difference between the order of execution like that. The
> difference should only be whether condition is being checked for truth
> or falsehood. In other word:
>
>  statement while condition
>
> and
>
>  statement until (not condition)
>
> should always be the same.
>
>
> David
>
> -- 
> David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
> Q: What's the best way to get a really solid knowledge of Ruby?
> A: Come to our Ruby training in Edison, New Jersey, September 14-17!
>   Instructors: David A. Black and Erik Kastner
>   More info and registration: http://rubyurl.com/vmzN


But David, should the behavior of:

  statement while condition

be different from:

  begin statement end while condition

which is what the issue boils down to. When the statement is enclosed  
in a block, it is evaluated once before the condition is checked.   
This is what I intended to show very explicitly in my response to Lloyd.

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com