# Yield should be renamed call\_block

**URL:** <https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888>\
**Category:** Ruby\
**Created:** [July 9, 2007, 2:10am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888 "2007-07-09T02:10:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 2:10am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/1 "2007-07-09T02:10:18Z")

</div>

One of the virtues of the Ruby language that is touted by just about  
everyone including the language designer Matz is that it is supposedly  
very intuitive, follows principle of least surprise, duck typing and on  
and on.  
I find it fascinating and quite a bit true. However, I have to always  
mentally translate the keyword “yeild” to mean “call\_block”. I find  
that it is the biggest distraction that I have when I am trying to  
figure out what and how a a method with a block and calling code  
interact. I can understand all that baggage such as “lambda” function  
name from Lisp and the wonderful “$” variables that came from Perl, but  
where did the keyword yeild come from? And why has not anyone aske Matz  
to consider changing it to infinitely more obvious “call\_block”? It it  
that big a deal? In an open source language?

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 2:18am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/2 "2007-07-09T02:18:01Z")

</div>

I find that “yield” describes what the method does even better than  
“call\_block”.

Besides, there is a principle in ruby’s design of having the most used  
methods be shorter.

It’s important because thinking “this function then yields” is far  
more consise than thinking “this function then calls call\_block”.

POLS, btw, is defined as “POLS to Matz”, and there is much emphasis on  
that.

Aur

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 2:30am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/3 "2007-07-09T02:30:02Z")

</div>

On 7/9/07, Bharat R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> where did the keyword yeild come from?  
> Intuivitely, a function yields its hold of the Vm/interpreter to its  
> caller. “Yield” is also used in some cooperative-threading  
> implementations, in which a thread yields control to the scheduler. I  
> don’t think the name is unintuitive at all. Besides, keywords should  
> be short, conscise, and why in the name of the Language Designer gods  
> should there be an underscore in a keyword?!

And why has not anyone aske Matz

> to consider changing it to infinitely more obvious “call\_block”? It it  
> that big a deal? In an open source language?

No, it’s not. You’re free to change the language so that “yield”  
becomes “call\_block” and release your own version. I don’t think it  
requires much tweaking. But I guess you’ll be the only user, so why  
bother?

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 2:34am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/4 "2007-07-09T02:34:03Z")

</div>

On 7/9/07, Simen E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > name from Lisp and the wonderful “$” variables that came from Perl, but  
> > to consider changing it to infinitely more obvious “call\_block”? It it
> 
> –
> 
> - Simen

“Intuivitely, a function yields its hold of the Vm/interpreter to its  
caller.” should be “Intuivitely, a function yields its hold of the  
Vm/interpreter to its  
block”, of course.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 5:45am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/5 "2007-07-09T05:45:15Z")

</div>

On Jul 8, 2007, at 7:58 PM, Yukihiro M. wrote:

> The “yield” keyword is used for this purpose from the ages of  
> languages for example in CLU. So if you learn the history and the  
> culture, you will find less problem.
> 
> I am not going to rename it. But in far future (3.0? maybe), the  
> keyword will be removed from the language, and you will access blocks  
> via block arguments of methods.
> 
> ```
> matz.
> 
> ```

to the OP, Of course with your won individual modules/libraries  
loaded/required, you can alias yield to be whatever isn’t already  
taken by something else. Ideas for aliases: yield\_to, call\_block,  
step\_out, segway, divert, fork, short\_fork, lunch\_break, junk\_time,  
call\_junk, goto ((hehehe…))

John J.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 7:39am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/6 "2007-07-09T07:39:21Z")

</div>

On Mon, Jul 09, 2007 at 09:32:26AM +0900, Simen E. wrote:

> Vm/interpreter to its  
> block", of course.

s/Intuivitely/Intuitively/

(as long as we’re correcting stuff)

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 2:59am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/7 "2007-07-09T02:59:06Z")

</div>

Hi,

In message “Re: Yield should be renamed call\_block”  
on Mon, 9 Jul 2007 09:10:23 +0900, Bharat R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|I find it fascinating and quite a bit true. However, I have to always  
|mentally translate the keyword “yeild” to mean “call\_block”.

The “yield” keyword is used for this purpose from the ages of  
languages for example in CLU. So if you learn the history and the  
culture, you will find less problem.

I am not going to rename it. But in far future (3.0? maybe), the  
keyword will be removed from the language, and you will access blocks  
via block arguments of methods.

```
          matz.

```

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 7:41am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/8 "2007-07-09T07:41:22Z")

</div>

On Mon, Jul 09, 2007 at 09:58:23AM +0900, Yukihiro M. wrote:

> culture, you will find less problem.
> 
> I am not going to rename it. But in far future (3.0? maybe), the  
> keyword will be removed from the language, and you will access blocks  
> via block arguments of methods.

That sounds pretty good – and more consistent across the language, too.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 7:41am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/9 "2007-07-09T07:41:22Z")

</div>

On Mon, Jul 09, 2007 at 12:43:57PM +0900, John J. wrote:

> > always  
> > matz.
> 
> to the OP, Of course with your won individual modules/libraries  
> loaded/required, you can alias yield to be whatever isn’t already  
> taken by something else. Ideas for aliases: yield\_to, call\_block,  
> step\_out, segway, divert, fork, short\_fork, lunch\_break, junk\_time,  
> call\_junk, goto ((hehehe…))

s/segway/segue/

. . . unless those scooter things are what you had in mind in the first  
place.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 11:19am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/10 "2007-07-09T11:19:38Z")

</div>

Hi,

Am Montag, 09. Jul 2007, 14:39:15 +0900 schrieb Chad P.:

> > I am not going to rename it. But in far future (3.0? maybe), the  
> > keyword will be removed from the language, and you will access blocks  
> > via block arguments of methods.
> 
> That sounds pretty good – and more consistent across the language, too.

It would mess up my whole code when I had to mention the bock  
parameter every time it’s obvious there is one.

None of my methods is longer than 40 lines and this is a  
habit I rely on every day. Pleeeease don’t remove the yield  
mechanism!

Bertram

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 10:30am UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/11 "2007-07-09T10:30:32Z")

</div>

John J. wrote:

> to the OP, Of course with your won individual modules/libraries  
> loaded/required, you can alias yield to be whatever isn’t already taken  
> by something else. Ideas for aliases: yield\_to, call\_block, step\_out,  
> segway, divert, fork, short\_fork, lunch\_break, junk\_time, call\_junk,  
> goto ((hehehe…))

yield is a keyword. It can’t be renamed or aliased.

- Charlie

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 12:19pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/12 "2007-07-09T12:19:46Z")

</div>

Hi –

On Mon, 9 Jul 2007, Yukihiro M. wrote:

> culture, you will find less problem.
> 
> I am not going to rename it. But in far future (3.0? maybe), the  
> keyword will be removed from the language, and you will access blocks  
> via block arguments of methods.

I’m curious what the rationale is for that. Also, will the block  
syntax be removed, in favor of Proc arguments?

David

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 1:46pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/13 "2007-07-09T13:46:57Z")

</div>

On 7/9/07, SonOfLilit [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I find that “yield” describes what the method does even better than  
> “call\_block”.
> 
> Besides, there is a principle in ruby’s design of having the most used  
> methods be shorter.
> 
> It’s important because thinking “this function then yields” is far  
> more consise than thinking “this function then calls call\_block”.

Agree 100%

> POLS, btw, is defined as “POLS to Matz”, and there is much emphasis on that.  
> Disagree a little bit, I have seen Matz telling so but I believe there  
> was a smiley attached.  
> Maybe one can say that Matz’ POLS is slightly more important than the  
> community’s POLS which is difficult to determine sometimes.

Why am I saying this? I have seen the “POLS is Matz’ POLS” frequently  
recently and I think the “real” POLS is indeed a great asset of Ruby  
even or because it is so difficult to determine. It would be a pity to  
lose this attitude.

It is of course clear that POLS for everyone is impossible ☹

Cheers  
Robert

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/14 "2007-07-09T15:12:51Z")

</div>

On 7/9/07, Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> def ntimes(n, &b)  
> n.times do  
> b.yield  
> end  
> end

It reads wrong, now, though - the block isn’t yielding, the current  
method is yielding _to_ the block. #run might be a better method name.

martin

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 2:08pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/15 "2007-07-09T14:08:59Z")

</div>

Hi,

In message “Re: Yield should be renamed call\_block”  
on Mon, 9 Jul 2007 19:17:13 +0900, removed\_email\_address@domain.invalid writes:

|\> I am not going to rename it. But in far future (3.0? maybe), the  
|\> keyword will be removed from the language, and you will access blocks  
|\> via block arguments of methods.  
|  
|I’m curious what the rationale is for that. Also, will the block  
|syntax be removed, in favor of Proc arguments?

The code

def ntimes(n)  
n.times do  
yield  
end  
end

would go like this

def ntimes(n, &b)  
n.times do  
b.yield  
end  
end

Rationals are:

- you can detect methods that don’t take blocks, that  
currently ignored silently.
- we can make yield sementics bit simpler.

The former is more prefereable.

```
          matz.
```

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 3:16pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/16 "2007-07-09T15:16:25Z")

</div>

Hi,

Am Montag, 09. Jul 2007, 21:06:58 +0900 schrieb Yukihiro M.:

> […] would go like this
> 
> def ntimes(n, &b)  
> n.times do  
> b.yield  
> end  
> end

s/yield/call/

Bertram

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 3:23pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/17 "2007-07-09T15:23:26Z")

</div>

On 7/9/07, Bertram S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> s/yield/call/
> 
> Bertram

I am with Bertram here, #call is describing what is done here.

Robert

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 3:28pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/18 "2007-07-09T15:28:27Z")

</div>

On Jul 9, 2007, at 7:06 AM, Yukihiro M. wrote:

> |I’m curious what the rationale is for that. Also, will the block  
> would go like this
> 
> def ntimes(n, &b)  
> n.times do  
> b.yield  
> end  
> end

the ‘&’ sigil is kind of scary. Reminds me of C. I’d be disappointed  
to see Ruby get more sigils.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/19 "2007-07-09T15:31:27Z")

</div>

On Jul 9, 2007, at 3:29 AM, Charles Oliver N. wrote:

> John J. wrote:
> 
> > to the OP, Of course with your won individual modules/libraries  
> > loaded/required, you can alias yield to be whatever isn’t already  
> > taken by something else. Ideas for aliases: yield\_to, call\_block,  
> > step\_out, segway, divert, fork, short\_fork, lunch\_break,  
> > junk\_time, call\_junk, goto ((hehehe…))
> 
> yield is a keyword. It can’t be renamed or aliased.

There is always (usually) a way to wrap something in a method. You  
can always make something def

John J.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 9, 2007, 3:32pm UTC](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888/20 "2007-07-09T15:32:27Z")

</div>

On Jul 9, 2007, at 8:27 AM, John J. wrote:

> > blocks  
> > end
> 
> the ‘&’ sigil is kind of scary. Reminds me of C. I’d be  
> disappointed to see Ruby get more sigils.

That’s nothing new for Ruby. It works today. It’s also needed.  
Without it, it wouldn’t be possible to save a block into a variable  
for later use.

James Edward G. II

[Next page](https://www.ruby-forum.com/t/yield-should-be-renamed-call-block/108888.md?page=2)
