in reply to (tye)Re3: Tie & Destroy, OOP
in thread Tie & Destroy, OOP

You are right that when I think it through carefully there are plenty of cases where it doesn't work. But if you have objects in a class which are backed by available data that you want to get a chance to save to disk, well then protecting that class in a Flyweight pattern gives you an opportunity to allow the data to be saved correctly.

I whipped up a proof of concept at Class::FlyweightWrapper. Take a look at how that works then look at the root node of this thread. I believe that if GMS::MemberFile was made into a wrapper around a private implementation through my new module, then DESTROY would work as desired. Sure, you can find situations where it would break, but it is at least a solution to the problem at hand.