in reply to Inheritable pragma ... or how I learnt perls' compilation order
I'm not sure I follow what you're trying to do, but my reading reminds me of BEGIN, UNITCHECK, CHECK, INIT, and END blocks, which I also don't fully understand.
If you want to ensure that there are no other constructors before you, I don't think you'll have much luck. Any code any where can bless into your class and cross its digits in hopes that nothing goes wrong.
I could imagine perhaps a new() method that notes its results (with weak references, of course) in a lexical hash. Then other methods in the class can check up on the objects they're called on in this table of "allowed" objects and throw a tantrum if a transgression is detected. There would be a performance penalty, of course. Also, you can't stop someone from "subclassing" via delegation. Such an object could even override UNIVERSAL::isa so as to pretend to be your object.
So what are you really trying to gain here? What is the rationale behind these requirements? What do you want to protect yourself against?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Inheritable pragma ... or how I learnt perls' compilation order
by Bloodnok (Vicar) on Aug 06, 2008 at 10:01 UTC |