You make a very good point about separating the 'name spaces' for the object's attribute storage and the method map.
Perhaps I am still half-asleep, but I think the curry method routine is wrong. I think you need to shift the object and method values off @_. Otherwise $meth will be called with args that look like: ($obj, $obj, $meth, ... ).
sub _curry_method {
my $object = shift;
my $method = shift;
return sub { $object->method(@_) };
}
I wonder if it makes sense to do this. I believe you wind up with a new closure for each method called on every instance of your bridge class. When I'm more awake I need to research how Perl handles garbage collection of code refs, and test to see if there any differences in memory or speed for this approach versus an AUTOLOADED method call.
Update:Yep, I was half asleep. plobsing's correct, the my ($o, $m) = @_; is fine. I blame it on Daylight Savings Time... I wasn't keeping the various meanings of @_ straight.
|