Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question:
Hello esteemed monks,
Say I have an object that has a construction phase that ends via a finalize() method. After that, no more modifications may be made.
Currently it is implemented via a lock within the object. However, I'm tempted to do a bless $self, "My::Module::Readonly"; and remove mutators from that class (or make them dying stubs).
This looks simple and efficient, but blessing an object into another package smells like a hack and/or abuse of Perl object system. What are the possible problems/pitfalls with such approach?
One thing that comes to mind is extending the initial class. Are there more?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problems and pitfalls with reblessing?
by choroba (Cardinal) on Nov 22, 2018 at 08:58 UTC | |
by Anonymous Monk on Nov 22, 2018 at 18:23 UTC | |
by choroba (Cardinal) on Nov 23, 2018 at 08:31 UTC | |
Re: Problems and pitfalls with reblessing?
by Anonymous Monk on Nov 22, 2018 at 07:56 UTC | |
by Dallaylaen (Chaplain) on Nov 29, 2018 at 09:20 UTC |