Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm sure that I don't really understand the way that you described that, likely because I have not read the rest of A12 yet.

However if you haven't nailed that part of the specification down, this discussion has convinced me that it would be a definite improvement to have a wildcard decision on whether to handle a method. That is, instead of writing something like an AUTOLOAD, you would write a method named something like CAN, which would dynamically decide whether or not to accept this method, and if it does, returns the subroutine that does it.

In thinking about it, I've had trouble coming up with anything that you'd want to do with a reasonable AUTOLOAD which cannot readily be duplicated by a CAN that works like this. Furthermore while it is very hard to make multiple inheritance and AUTOLOAD cooperate, this CAN strategy cooperates with multiple inheritance rather smoothly. In fact it returns the best possible for can() to "definitely has a method of this name", even in the face of multiple inheritance and wildcard methods.

Unfortunately if a user wanted to implement this in Perl 6, as I understand your paragraph they would not be able to pass the extra information to can() that, "I can really tell you whether I'll do that". Which prevents can() from giving the answer that we probably really wanted it to give.

In fact I'm seriously thinking of writing a module named something like UNIVERSAL::AUTOLOAD_CAN which implements a UNIVERSAL::AUTOLOAD and UNIVERSAL::can that implements this solution in Perl 5. This would make it possible to get can(), AUTOLOAD and multiple inheritance to play together. (But only if you write no other AUTOLOADs!)


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

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-03-28 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found