On Fri, 2004-04-30 at 19:01, Larry Wall wrote: > That would almost certainly fail with an error saying that it couldn't > find your &new subroutine. The & sigil does not imply dispatch, and > the default .new is inherited, not autogenerated, last I checked. :-)
ouch. too true. so I guess my Animal class should be written as: class Animal { our @.zoo; method new(Class $class: *%_) { my $self = $class.bless(0, *%_); push(@.zoo, $self); return $self; } } but: what if Animal does inherits from something else? what I would like to do (what I was trying to do with wrappers, that is) is to call the inherited constructor, then do something with the returned object. something like: method new(Class $class: *%_) { my $self = $class.WALK[:omit(::_)].new(*%_); push(@.zoo, $self); return $self; } this is based, of course, on the assumption that ::_ always contains "Animal", even when building a "Lion is Animal" object. or, if I read correctly the paragraph in "Calling Superclasses, and Not-So-Superclasses": Now, sometimes you want to call the net method, but you want to change the arguments [...] If you use the call keyword in an ordinary (nonwrapper) method, it steals the rest of the dispatch list from the outer loop [...] perhaps my method could be: method new(Class $class: *%_) { my $self = call($class, *%_); push(@.zoo, $self); return $self; } but are the arguments still passed correctly (eg. $class as the invocant) in this case? cheers, Aldo