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?


In reply to Re: Inheritable pragma ... or how I learnt perls' compilation order by kyle
in thread Inheritable pragma ... or how I learnt perls' compilation order by Bloodnok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.