[#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

Re: Proc initialize method not called under certain circumstances

From: "Marcel Molina Jr." <marcel@...>
Date: 2007-06-28 22:38:22 UTC
List: ruby-core #11553
On Fri, Jun 29, 2007 at 06:54:49AM +0900, MenTaLguY wrote:
> On Fri, 29 Jun 2007 06:24:48 +0900, "John Lam (CLR)" <jflam@microsoft.com> wrote:
> > So, is it correct to assume that for language constructs that create
> > built-in types like Range, Array, Hash etc that user-defined initialize
> > methods are never called?
> 
> Yes.  Generally, Class.new calls .allocate and then #initialize on the returned
> object, but there's no guarantee that either of those methods will be used if
> the object is created a different way and/or if .new is overridden for a particular
> class.

It's not just a matter of "no guarantee", it straight up does not happen much
in a similar way as what John is asking about Proc.new vs lambda vs a method
with a block argument.

>> class Class; def initialize(*args, &block) super; puts 'hello' end end
=> nil
>> Class.new
hello
>> class Foo; end
=> nil

In eval.c, the NODE_CLASS case eventually calls rb_define_class_id which
itself calls rb_class_new which in turn calls rb_class_boot which creates the
RClass struct and sets its members.

rb_class_new_instance is never called though, which is what new is mapped to
for rb_cClass.

From my understanding, that's the reason there is that behavior for class
creation. I'd assume something similar is true for Proc's. 

Really though, I think John is wondering if this is intentional and if
so why. I'm interested in the answer to that too :)

marcel
-- 
Marcel Molina Jr. <marcel@vernix.org>

In This Thread