http://qs1969.pair.com?node_id=95104


in reply to Class::Flyweight - implement the flyweight pattern in OO perl

I don't see very much Flyweight going on here. You may want to call your package Class::Privacy. Explanation: You store a scalar per instance, provided the instance stores a scalar too. No space saved. The Idea of Flyweight is: Many instances store common values (mostly arrays and hashes (or records in other languages)),that are related, as one constant value represented as a pointer (or ref) thereby saving memory, provided they don't modify the pointed to value. Modifyability is achieved by not only storing the pointer but overriding values in the instance too in the hope that many values are common and only a few must be overridden. An instance can modify its value by changing the pointer (and possibly choosing appropriate overrides) too. NOTE: The pointer is not the constant, it's the pointed to value that's constant.