Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Yep, this have the advantage to avoid AUTOLOAD. But consider the following point: If you put my AUTOLOAD method in a module called AutoAccess, you just have to write something like
package Foo ; use base qw/AutoAccess/ ; sub new{ bless { 'a1' => undef , 'a2' =>undef } , shift ; } 1;
To have the benefits of the auto accessors. The methods 'a1' and 'a2' are implemented 'on demand' to use the nowadays buzzword :) If you'd like to change the implementation and want to keep the behaviour of the class from the user code point of view, you just have to implement by hand the concerned accessor methods. Anyway, I also think that explicitely write which attribute should be concerned by auto accessor generation can be a good thing. Specialy to write code that don't look too magic to new readers :) Is there a way to use the 'my @attributes = qw(color speed);' method in a factorized way ?

In reply to Re^2: Answer: How can I use AUTOLOAD to magically define get and set methods for my member data? by jeteve
in thread How can I use AUTOLOAD to magically define get and set methods for my member data? by Anonymous Monk

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 admiring the Monastery: (7)
As of 2024-04-19 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found