in reply to Prototype Failing?

I got your code to work by changing the order of sub selftest and sub _self declarations in your source:
# With selftest declared after _self % perl -MO=Deparse test.pl ... sub Data::Validate::OO::selftest (@) { package Data::Validate::OO; my $self = &_self(\@_); # <---- look here print Dumper(@_); } ... # Now with selftest declared after _self % perl -MO=Deparse test.pl ... sub Data::Validate::OO::selftest (@) { package Data::Validate::OO; my $self = &_self(@_); # <---- and here print Dumper(@_); } ...
The compiler doesn't yet know about the prototype as it is parsing the line that contains my $self = _self(@_), so it doesn't know it must pass the array by reference. Either put an empty prototype at the top of the package, or switch the order of the subs in your source code.

Incidentally, a prototype of (@) like you have in the selftest sub is equivalent to declaring no prototype at all. And as already mentioned, not honored for a method call anyway.

blokhead

Replies are listed 'Best First'.
Re: Re: Prototype Failing?
by Flame (Deacon) on Jan 27, 2003 at 05:00 UTC
    ... Wow... behold the power of order... I'll have to keep that in mind. Yeah I know @ might as well not be there, it's there because I got in the habit while designing the tests (it determines the number of arguments to pass to a test via the prototype function. Tricky, but avoids extra fields of 'this many args')

    Thanks!



    My code doesn't have bugs, it just develops random features.

    Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)