Clear questions and runnable code
get the best and fastest answer
Ok. First off in general I agree with most of what your saying. But I think that you have slightly missed my point.
I think the crux of the matter is highlighted in these two sentences
The motivation for doing it is data-hiding, not reducing duplicate state.
The point I was trying to make was with the flyweight pattern as described by TheDamian we can do both of these things. The overall design facilitates it much more than most other OO perl models i've seen.
(I think you do have to read that "allows" as meaning that objects are reused - otherwise it's just a null statement)
This one of the few points where I do disagree with you. I think the allows is crucial. Sharing objects in perl in the way that they mean here is not particularly convenient. However sharing attribute data is. And as I think the core objective is to reduce overhead by sharing data, the particular mechanism by which this is effected is not particularly relevent. And the flyweight pattern allows this to be done in an easier way than most other object models.
Lets put it this way, if you or I sat down to implement a flyweight object system, or a shared attribute system, we would end up with an implementation that is basically the same as TheDamians.
Here we talk about sharing objects with the same state. The motivation is to reduce the overhead in having a multitude of objects.
No. The motivation is to reduce overhead by not duplicating data. Sharing objects is just an means to an end.
I agree however that this debate has degenerated ;-) into quibbles. However for me (and I think you too) its been a fun and educational trip.
In reply to Re: Re^6: Flyweights - different meaning in perl?