Bob Rogers wrote:
   Sometime between r11268 (probably) and 11276, there was a change to
the way that initialization methods get called, regardless of whether
"__init" or a 'BUILD' property is used.  If I do

        .local pmc foo, hash
        .local int foo_class
        foo_class = find_type "User::Foo"
        foo = new foo_class, hash

to construct the object, the build method gets ".param pmc hash" bound
to the hash, as happened in earlier versions, and it works.  If I
instantiate the same class without a hash via a string constant:

        .local pmc foo
        foo = new "User::Foo"

then the build method sees self in the hash parameter, and dies.  It's
not obvious to me how this is happening.  Are these somehow getting
treated differently by the new argument passing code?  TIA,

I've added a test using __init with and w/o an argument and it works as expected (see t/pmc/objects.t - last one). As the __init function is called with differing args, it has to have a signature:

.sub __init :method
   .param pmc arg :optional

It's of course debatable, if we should consider an argument as flattening by default and call init with a signature

  "vO%"  or "vO@"

where '%' and '@' denote flattening hash or array respectively.

(Your test is hard to follow and it takes a lot of time to dig through all the method calls)

Ome remark: I don't see any advantage in using the BUILD property - just the opposite - it's the only builtin method call that can be given another name, it complicates the object creation code, well and it's for sure a lot slower then just using __init.

I'm in favour of removing it.


                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/

leo

Reply via email to