[#11439] comments needed for Random class — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

15 messages 2007/06/12

[#11450] Re: new method dispatch rule (matz' proposal) — David Flanagan <david@...>

This is a late response to the very long thread that started back in

17 messages 2007/06/13

[#11482] Ruby Changes Its Mind About Non-Word Characters — James Edward Gray II <james@...>

Does this look like a bug to anyone else?

10 messages 2007/06/16

[#11505] Question about the patchlevel release cycle — Sylvain Joyeux <sylvain.joyeux@...4x.org>

1.8.6 thread support was broken in bad ways. It stayed for three months

20 messages 2007/06/20
[#11512] Re: Question about the patchlevel release cycle — Urabe Shyouhei <shyouhei@...> 2007/06/20

Hi, I'm the 1.8.6 branch manager.

[#11543] Re: Apple reportedly to ship with ruby 1.8.6-p36 unless informed what to patch — James Edward Gray II <james@...>

On Jun 27, 2007, at 4:47 PM, Bill Kelly wrote:

10 messages 2007/06/27

Proc.==

From: David Flanagan <david@...>
Date: 2007-06-05 04:37:08 UTC
List: ruby-core #11401
Can anyone construct two proc objects p1 and p2, without using clone or 
dup, so that p1==p2 but p1.object_id != p2.object_id?

I thought this code would do it, but it does not:

def blah
   Proc.new  # return block as a proc
end
pr1 = Proc.new { |x| x*x }
pr2 = blah(&pr1)
puts pr1==pr2                        # true
puts pr1.object_id == pr2.object_id  # true, so they're the same object

Unless I'm missing something here, I think the documentation for Proc.== 
is misleading.  It says:

   Return +true+ if _prc_ is the same object as _other_proc_, or if
      they are both procs with the same body.

Based on this, I would think that:

   lambda {|x| x*x } == lambda {|x| x*x }

But this expression return false in both ruby 1.8 and 1.9.

So anyway, unless I'm missing some obvious way to construct two procs 
"with the same body" I think the documentation should be clarified.  I 
suggest something like:

   Return true if prc is the same object as other_proc, or if one is a
   clone or duplicate of another.  Two procs created from distinct blocks
   are not equal, even if those blocks have identical source code.

     David Flanagan

In This Thread

Prev Next