On Tue, May 04, 2004 at 03:41:58PM +0200, Aldo Calpini wrote: : 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.
I believe that's correct, but my caffeine dosage hasn't hit LD50 yet... : 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? It'd be pretty useless if it didn't work right... Whether the subroutine-call form would work is an interesting question. Either the implementation of call has to recognize that it's propagating a method call with a required invocant as its first argument, or you might have to say my $self = call($class: *%_); or my $self = $class.call(*%_); to indicate that you don't mean my $self = call(*%_); presuming that call is smart enough to realize that you do want the invocant added in. But it seems like bogus dwimmery for something that won't be used terribly often, especially when the my $self = .call(*%_); form is available (presuming you haven't rebound $_ to a different topic). Requiring method syntax would also further differentiate this from a true wrapper call(). But it would be another predefined magical method like .meta or .dispatch... Larry