in reply to How Are Attributes Useful?
I'm not an expert, but I can bring some of my C experience to bear.
The C language is bound closely to assembler, and as such has certain keywords that act like the attributes that you're talking about. One that comes to mind is volatile, a variable declaration modifier that signals the compiler that whenever that variable was used in an expression, its value had to be read from the memory location assigned to it -- because its value was volatile.
Another example is the lock attribute discussed in the Camel (pp. 457-458); it gives the compiler a hint that only the thread that has locked a function is allowed to call it. This is an attempt to prevent a race condition.
Finally, there's the oxymoron of the constant variable -- that's just a convenience that allows a constant value to be stored in a read-only variable. Any attempt to update this variable's value will be ignored.
So to answer your question -- attributes are used to give hints to the compiler and the run-time about special treatment to be given to certain variables and functions. And sometimes that behaviour isn't fully defined -- it's to leave future perl developers (note the lower case 'p') room to expand, as necessary.
Alex / talexb / Toronto
"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How Are Attributes Useful?
by beauregard (Monk) on Jan 18, 2005 at 22:55 UTC | |
Re^2: How Are Attributes Useful?
by Limbic~Region (Chancellor) on Jan 19, 2005 at 00:40 UTC | |
by xdg (Monsignor) on Jan 19, 2005 at 05:03 UTC |