omkellogg has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to name an anonymous reference
by ikegami (Patriarch) on Dec 18, 2017 at 02:10 UTC | |
by omkellogg (Novice) on Dec 18, 2017 at 07:16 UTC | |
|
Re: how to name an anonymous reference (dictionary/hash)
by beech (Parson) on Dec 18, 2017 at 03:36 UTC | |
|
Re: how to name an anonymous reference
by Anonymous Monk on Dec 17, 2017 at 22:09 UTC | |
by omkellogg (Novice) on Dec 17, 2017 at 22:52 UTC | |
|
Re: how to name an anonymous reference
by LanX (Saint) on Dec 17, 2017 at 22:30 UTC | |
by ikegami (Patriarch) on Dec 18, 2017 at 02:09 UTC |