comp.lang.ada
 help / color / mirror / Atom feed
* Attribute definition clause for 'External_Tag
@ 1999-05-16  0:00 David C. Hoos, Sr.
  1999-05-17  0:00 ` Robert Dewar
  0 siblings, 1 reply; 2+ messages in thread
From: David C. Hoos, Sr. @ 1999-05-16  0:00 UTC (permalink / 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.







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-05-17  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-16  0:00 Attribute definition clause for 'External_Tag David C. Hoos, Sr.
1999-05-17  0:00 ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox