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

* Re: Attribute definition clause for 'External_Tag
  1999-05-16  0:00 Attribute definition clause for 'External_Tag David C. Hoos, Sr.
@ 1999-05-17  0:00 ` Robert Dewar
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1999-05-17  0:00 UTC (permalink / raw)


In article <8b1tUD#n#GA.208@newstoo.hiwaay.net>,
  "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> wrote:
> 1.  Should the 'Image attribute be allowed to define
>     an external tag?

No, because this is not a static expression (you ask why not,
and I am not sure if you are asking a question about the RM,
in which case, the answer is simply that it is not in the list
of static expressions), or about the philosophical design of
Ada 95. If the latter, the answer is simply to keep things
simple, you have to make an arbitrary cut on static expressions,
and this one did not seem important enough.

> 2.  Should the compiler reject identical External_Tag
>     attributes for types with a common ancestor?

Certainly not, what RM authority would there be for such
rejection. Sure it is a bit odd if the programmer does this,
but I see no illegality here. If you think it is illegal, please
give your argument from the RM.

A warning would be reasonable perhaps ...


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




^ 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