in reply to Why isn't ->can() curried?
I don't want to do either often, but on the rare occasions when I do, your suggestion is less convenient than the current behaviour.
But more than that, the vast majority of the time when people want to check can they just want to check truth. Why create a closure just to see it get thrown away?
But if you really want it, just create another method to do what you want:
And now you can curry a method, and curry a few arguments as well while you are at currying favour. And I still get the can that I know and like.sub UNIVERSAL::bind_meth { my ($self, $meth, @args) = @_; my $func = $self->can($meth); if (defined($func)) { return sub {$func->($self, @args, @_)}; } else { return undef; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why isn't ->can() curried?
by diotalevi (Canon) on Jan 20, 2003 at 19:00 UTC | |
by Anonymous Monk on Jan 20, 2003 at 21:11 UTC | |
by diotalevi (Canon) on Jan 20, 2003 at 21:36 UTC |