Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.


In reply to Re: Re: Re: Re: Re: Why breaking can() is acceptable by stvn
in thread Why breaking can() is acceptable by tilly

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2023-09-28 07:06 GMT
Find Nodes?
    Voting Booth?

    No recent polls found