in reply to Re: Re: Re: Re: Why breaking can() is acceptable
in thread Why breaking can() is acceptable
With your code snippet, if someone has an object of your class (or a class that inherits from your class) and wants to know if you can foo, where it can foo because of your AUTOLOAD, then your can will say that it can't foo because the person calling can is not making that call from within your class
LOL, you are right, I updated the code to reflect my dumb mistake. Once again, waaaay past my bedtime.
As for how it might affect subclasses (and please note I specifically did not handle subclasses in the code). It is your responsibilty when subclassing to take care of stuff like this. Sure that might be a little to "white-box" for some, but again, if you are using AUTOLOAD in the presence of inheritance, you are already in trouble, so you should expect to get your hands dirty.
My belief is that p5p adding to Perl should not invalidate accepted practices. My further belief is that of AUTOLOAD and can, AUTOLOAD matters more to most Perl developers.
This may be so, but again I dont like it much, so I am biased. No matter how old AUTOLOAD is though, I am wary of using it too much with inheritance, to me it just sounds like a bad idea. But again, these are my opinions, nothing more.
Going further, my impression is that people who are familiar with other dynamic languages are more likely to want to reach for something like AUTOLOAD (perhaps they'll call it method_missing, but they expect it to be there) than they will can.
I dont know if i agree with this, I can see where AUTOLOAD can be a nice tool, but I wonder if you are not restricting your view of can too much. In alot of ways they are similar, can being just a more manual approach. I think people who might be comfortable with using class reflection would be more likely to go for can, where as those more familiar with run-time code generation would reach for AUTOLOAD. Both are common aspects of dynamic languages though.
My conclusion, therefore, is that someone who wants developers to not break can with AUTOLOAD is fighting an uphill battle.
Alot of this depends upon in what context this is all being used/implemented, we are debating a wide open field here. But I do not think it is unreasonable to expect that can is not broken in an OO module. IMO, one should not play lightly with AUTOLOAD and objects. More imperative-style modules is another story, which I would guess (although I dont know) is the more common usage of AUTOLOAD historically.