Now I'm looking for feature suggestions, and ideas for good examples.
There are two feature possibilities that I have thought of.
The first is to provide an easy way to know within CAN what call-level you have to go to to get to the call that asked for the method. This would be useful if, for instance, someone wanted to implement a module that allowed for creating private or protected methods. The only problem is the API. I could set a global variable. But what do I call it? And if I export that then I can't use local to localize it.
The second is some version of NEXT. Of course the built-in SUPER or TheDamian's module won't work because they can only find the AUTOLOADs which are all pretty much the same. I need to have the logic in Class::AutoloadCAN. So I have to decide how to do it. The obvious way is to provide in the AUTOLOAD a "next" method. One question is how I should handle the "dreaded diamond". Do you avoid calling methods in the inherited superclass twice, or do I try to call methods in the inherited superclass twice?
There is a subtle conflict. It is nice that $obj->foo(@args); is always the same as $obj->can("foo")->(@args); but making that true with the next extension that I have proposed means breaking using $this->can("foo") == $that->can("foo") to test if two objects have the same method. I don't think that people would really mind if the latter broke, particularly considering what they get for it, but I'm not a heavy user of UNIVERSAL::can so I don't know how people like to use it. If you care either way then holler.
Now good example ideas. The most obvious one is to implement a class that allows you to do this:
Perhaps people would prefer the syntactic sugar of:private foo => sub { ... }; protected bar => sub { ... }; # The only reason for this is so that it can call on # private and protected versions of baz in a superclass, # and that requires the "next" functionality that I # thought of. (Guess how I realized that "next" might # be nice to have?) public baz => sub { ... };
even though it means using a source filter with the attendant fragility.private foo { ... } protected bar { ... } public baz { ... }
I think that people might want this because I've seen people complain of the lack of it in Perl, but I have no idea what a module that provides this should be called. Or what it further features it should have.
Feedback and further suggestions solicited.
In reply to RFC: Class::AutoloadCAN by tilly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |