From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Attribute definition clause for 'External_Tag
Date: 1999/05/16
Date: 1999-05-16T00:00:00+00:00 [thread overview]
Message-ID: <8b1tUD#n#GA.208@newstoo.hiwaay.net> (raw)
Here's one for all the language lawyers out there...
I wanted to relate the tags of a group of types all
derived from a common abstract ancestor to the values
an enumeration type whose values relate to the
tagged types.
To do this I used an attribute_definition_clause to
specify the External_Tag attribute for each of the
tagged types.
My first approach was to use an clause of the form
for Tagged_Type'External_Tag use
Enum_Type'Image (Enum_Value);
I was surprised that the compiler complained that
the expression must be a static string.
Why is such an expression not static?
My next approach (the one I'm now using) was to
replace the clause with one of the form
for Tagged_Type'External_Tag use "ENUM_VALUE";
This is fine, as long as the string exactly
matches the 'Image attribute, and I can simply
relate Tags to enumeration values.
E.g., I can say
Enum_Var := Enum_Type'Value
(Ada.Tags.External_Tag
(Tagged_Type_Item'Tag));
However, I was even more surprised than I was about
the staticness issue when I saw that the compiler
did not complain if the same External_Tag attribute
is defined for two different types of the same class
-- i.e., descended from a common tagged ancestor.
What say ye?
1. Should the 'Image attribute be allowed to define
an external tag?
2. Should the compiler reject identical External_Tag
attributes for types with a common ancestor?
David C. Hoos, Sr.
next reply other threads:[~1999-05-16 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-05-16 0:00 David C. Hoos, Sr. [this message]
1999-05-17 0:00 ` Attribute definition clause for 'External_Tag Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox