in reply to enabling OO and non-OO access to the same module using a hash reference
But the problem I am actually having with providing support for a coerced hash (or even an ordered list of parameters for that matter) is this:
Just to make it clearer we'll say OtherModule is a subclass of Package. So the problem is that testing for OO-access in Package::method will go false-positive if the above non-oo construction is used. Requiring all non-OO users to use a hash reference for their parameters makes it (a) easier to test access method and (b) code applying to the object reference that normally arrives will work compatibly at once if a hash reference is passed non-oo intead. So this is why I am hoping I can go that route. For example, perlbot even suggests testing ref($_[0]) as an alternative to the forbidden (ref($_[0]) eq 'ClassName'). But that would prevent some trivial methods from having say a file handle as parameter owing to the same false-positive result I am trying to avoid. And I don;t want to have to test all possible references that aren't to some class! (update: because a class is not allowed to make assumptions about subclasses so that would be what had to be tested for a completely generic test for oo-ness)my $oref = OtherModule -> new(); Package::method( $oref, 'gotcha' );
-M
Free your mind
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: enabling OO and non-OO access to the same module using a hash reference
by ysth (Canon) on Jan 16, 2007 at 01:10 UTC | |
|
Re^2: enabling OO and non-OO access to the same module using a hash reference
by ikegami (Patriarch) on Jan 16, 2007 at 04:05 UTC |