Hi --

On Wed, 11 Jul 2007, ara.t.howard wrote:

>
> On Jul 10, 2007, at 3:33 PM, dblack / wobblini.net wrote:
>
>>> Since I am not a English speeker and I usually dont use that particlar
>>> word, I feel like "yield" as rather like a symbol vaguly related to
>>> passing valu to the blok.
>> 
>> Vagueness would be OK, maybe, but the problem is bigger than that:
>> it's that "block.yield" just doesn't express what's happening.
>
> i'm with matz on this one
>
> block.yield
>
> reads, to me, simple as
>
> 'doing my own thing...'
>
> block.yield 'control to you'

But "yield" does not mean "take control".  It means relinquish
control.  That's why it makes sense as a control-flow directive --
control, independent of any specific object-messaging, switches upon
"yield" -- and not as a message being sent to an object.  That object
is not supposed to relinquish control, so it doesn't make sense to ask
it to.

And if you interpret it as more like "thread.kill" than like
"string.split" (i.e., telling the system to kill a thread, rather than
telling a string to split), then you're telling the system to yield a
block.  But the system doesn't yield blocks; it yields (relinquishes
control) *to* blocks.

I suspect that if we didn't have the 'yield' keyword and the process
of making a transition to having it be message-style, I don't think
"yield" would ever show up as a suggestion for a name for this method
(though of course an astonishing number of terms show up in the
various free-for-all method-name suggestion fests :-)

> or
>
> accum << block.yield

That still doesn't tell me what it means for a block to yield.  I
think I smiley-ly suggested:

   yield >> block

earlier, but I actually think that's much better than block.yield.
Make yield explicitly yield to a variable, if necessary, but don't
send the message "yield" to an object that has no intention of
yielding anything, nor any intention of being yielded.

> it's especially easy if you happen to think of blocks as a specialized form 
> of co-routinues, which i happen to.

I do too; they're co-routines to which control is yielded.  They yield
control *back*, but that's another matter :-)


David

-- 
* Books:
   RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242)
   RUBY FOR RAILS (http://www.manning.com/black)
* Ruby/Rails training
     & consulting:  Ruby Power and Light, LLC (http://www.rubypal.com)