Let there be a small language for creating annotations. (The actual case in point is section 7.4.15 in OMG IDL4, http://www.omg.org/spec/IDL/4.1/PDF).

Some annotations are predefined. In order to support both predefined annotations and user defined annotations, I would use an array, e.g.:

sub ULONG () { 9 } sub ENUM () { 23 } my @annotations = ( [ "id", [ ULONG, "value", undef ] ], [ "autoid", [ ENUM, "AutoidKind", [ "SEQUENTIAL", "HASH" ] ], [ $annotations[1]->[1], "value", "HASH" ] ] );

The idea is that the array is initialized with the predefined annotations, and user defined annotations are parsed and appended onto the same array later on.

In the example above, the predefined annotation autoid first defines an enum type AutoidKind with values SEQUENTIAL and HASH, and then shall define a parameter named value of the enum type just defined.

The notation $annotations[1]->[1] for referencing the enum type does not work - probably because the declaration @annotations is still in progress at the point of reference.

Perhaps there is a different way to achieve what I am trying to do?

Thanks.

In reply to how to name an anonymous reference by omkellogg

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.