Larry Wall <[EMAIL PROTECTED]> writes: > On Thu, Nov 21, 2002 at 01:29:32AM -0500, Tanton Gibbs wrote: > : Properties have bothered me, but for a different reason. It appears that > : everyone's answer to everything is "make it a property!" > > Yes, properties should generally be a last resort, not a first resort. > > : Properties are just strange to comprehend...they are like hidden attributes > : that are squirreled away until you least expect them...then > > Think of them as creating a singleton class with extra attributes. > > : they pop up and bite you. I've never gotten the warm fuzzies from > : properties, new ones just appear out of thin air and I feel like they > : are the kitchen sink feature of Perl6 > > They're more like a safety valve feature for when your class system just > doesn't get you from here to there.
I've tended to think of them as 'footnotes'. For instance, in a Perl 5 project I'm working on (a persistence system) I found myself needing to associate 'management' data with arbitrary objects and I didn't want to go messing with the internals of those objects (especially as my 'management' objects would need to have DESTROY type behaviour and there was no guarantee that the managed objects wouldn't) so, having first given myself *massive* headaches managing singleton classes and blessing managed objects into 'shadow' classes I found myself thinking "Wouldn't it be cool if I could hand a Perl 6 type property off any object?" and a few lines of XS later I had the very thing. What was my point? Oh yes. Perl 6 properties are great because they're 'cross cutting', you can hang a property of *anything* and use it for your own nefarious purposes (just be careful with namespaces) and the object's Class need never been aware of the extra goodies. Dangerous, but sometimes nothing else will do. -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen?