Object-InsideOut - Passing 'straight' arguements to a constructor.

Posted on Wed Jan 4 23:30:12 2006 by arguile
Passing 'straight' arguements to a constructor.

While for more advanced object initialization the whole InitArgs method is great, for some object construction I'd prefer access to @_ as passed to new. Especially when recreating existing APIs.

I've been looking through the documentation and source code and can't seem to find a simple way to do it. All any init method gives me is a hasref. Coercing (kludging) it back into an array doesn't work as uneven parameters yields an exception and references are stringified if they occupy a hash key location.

# Example my $foo = Some::Thing->new(4,5,6); package Some::Thing; { sub _init :Init { my ($self, @args) = @_; # $args->[1] == 5 at this point. } }

Am I just missing something? Idea?

Direct Responses: 1589 | Write a response