[#1263] Draft of the updated Ruby FAQ — Dave Thomas <Dave@...>

33 messages 2000/02/08

[#1376] Re: Scripting versus programming — Andrew Hunt <andy@...>

Conrad writes:

13 messages 2000/02/15

[#1508] Ruby/GTK and the mainloop — Ian Main <imain@...>

17 messages 2000/02/19
[#1544] Re: Ruby/GTK and the mainloop — Yasushi Shoji <yashi@...> 2000/02/23

Hello Ian,

[#1550] Re: Ruby/GTK and the mainloop — Ian Main <imain@...> 2000/02/23

On Wed, Feb 23, 2000 at 02:56:10AM -0500, Yasushi Shoji wrote:

[#1516] Ruby: PLEASE use comp.lang.misc for all Ruby programming/technical questions/discussions!!!! — "Conrad Schneiker" <schneiker@...>

((FYI: This was sent to the Ruby mail list.))

10 messages 2000/02/19

[#1569] Re: Ruby: constructors, new and initialise — Yukihiro Matsumoto <matz@...>

The following message is a courtesy copy of an article

12 messages 2000/02/25

[ruby-talk:01458] Re: new reserved word for yield (was Re: Scripting versus programming)

From: Dave Thomas <Dave@...>
Date: 2000-02-16 14:41:24 UTC
List: ruby-talk #1458
Pixel <pixel_@mandrakesoft.com> writes:

> a question that makes me wonder, is what the difference between the 2 following:
> 
> 
> def f(a, b, c, *l)
>    ...
>    ... yield(...) ...
>    ...
> end
> 
> def f(a, b, c, *l, &f)
>    ...
>    ... f.call(...) ...
>    ...
> end

I asked an identical question a while back. I got the following answer 
from Clemens


     AFAIK --if I have understood matz right-- there is only a
     performance penalty by using your second example. That is, as a
     block has to converted into a Proc instance *and*then* passed
     over to the method. A further penalty has to be added for every
     call, as yield'ing a block is faster than call'ing a Proc
     instance!

And then a followup from matz

     I forgot to mention one big difference.  You can't swap self with
     instance_eval() as in [ruby-talk:01010] by using yield.  &block
     is the only way to pass blocks around directly.

     You can use {|x| yield x} trick for most of the cases, but not
     for the instance_eval() case.


Regards


Dave

In This Thread

Prev Next