Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: How Are Attributes Useful?

by Limbic~Region (Chancellor)
on Jan 19, 2005 at 00:40 UTC ( [id://423227]=note: print w/replies, xml ) Need Help??


in reply to Re: How Are Attributes Useful?
in thread How Are Attributes Useful?

talexb,
I don't mean offense, but this really doesn't help at all. The only example of attributes that I have seen that doing anything useful are the built-in ones that I mentioned in my question. You have described them without providing an example which is the same problem I had with the documentation. Can you give me an example of using attributes to make a read-only variable/sub? The question was looking for something tangible and to me this is just window dressing.

Cheers - L~R

Replies are listed 'Best First'.
Re^3: How Are Attributes Useful?
by xdg (Monsignor) on Jan 19, 2005 at 05:03 UTC

    Look at Attribute::Protected and Attribute::Property. More specifically, look at their source to see what they're doing. Essentially, both are inserting some extra code that runs (fairly transparently) in advance of the code block you provided with the subroutine definition.

    There are legitimate issues around when attributes get run (i.e. during the CHECK phase by default) and whether this is mod_perl safe, but this can be coded around as some others have mentioned. Personally, I think they're an interesting concept that hasn't matured properly yet. Essentially, it's an attempt at specifying behavior as a bunch of building blocks -- another way of templating functionality and reducing redundant code.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://423227]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-03-19 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found