comp.lang.ada
 help / color / mirror / Atom feed
From: troll <wisniewski.ru@gmail.com>
Subject: tagged primitive operation and freezing
Date: Fri, 12 Nov 2010 19:24:44 -0800 (PST)
Date: 2010-11-12T19:24:44-08:00	[thread overview]
Message-ID: <ab723ba2-d798-46e8-a0e6-0d2401cce19e@r31g2000prg.googlegroups.com> (raw)

The following code snippet does not compile under two compilers that
we have tried. Working with one of the vendors, we were wondering at
first whether or not it should compile as in whether the instantiation
is a freezing occurrence per 13.14:(5) and therefore the tagged
primitive operation should be illegal, per RM95 3.9.2:(13) and 13.14:
(16)

Our reasoning (with the vendor) now as to why we agree that it
shouldn't compile is based on the following. We wanted to run this by
this group for any contrarian opinions or underlying reasons why this
does not and should not compile.




From a compiler implementation perspective, the instantiation (rather
like a macro expansion) will precede the primitive operation itself,
even though the two are really conceptually coincident declarations.
Should the primitive operation be allowed, no matter what the contents
of the instantiation?

Suppose the instance elaboration happens to declare some objects, and
dispatch some primitive operations of its own type?    It would
violate the intent of the above rules.    Should this still be
allowed?     I hope not.

and also then this would NOT apply to UNTAGGED TYPES because (???)

    13.14:(16): "[The explicit declaration of a primitive subprogram
of a
    tagged type shall occur before the type is frozen (see 3.9.2).]"

    3.9.2:(13): "The explicit declaration of a primitive subprogram of
a tagged
    type shall occur before the type is frozen (see 13.14).  [For
example, new
    dispatching operations cannot be added after objects or values of
the type
    exist, nor after deriving a record extension from it, nor after a
body.]"

 Notice that Annotated Ada RM95 3.9.2:(13.c) clarifies:
   "We considered applying this rule to all derived types, for
uniformity.
    However, that would be upward incompatible, so we rejected the
idea."

That means untagged types can add more new primitive ops even after
the type is frozen.  Yes!
It seems the belief is that there's no harm in it, although  it would
be confusing (counter-intuitive)
if that primitive op was overridden because the old overridden (not
new overriding) primitive op body
would reemerge (ie, still be called), same as in Ada83.


generic
  type Object_T is private;
procedure blah ( Param : Object_T );

-------

with blah;
package oops is
  type a is tagged null record;  -- any tagged type

 -- must be a type extension to induce
failure:
  type Flight_T is new a with null record;  -- fail

  function b (Flight : in Flight_T) return String;

  procedure c is new blah
     (Object_T => Flight_T);

end;



             reply	other threads:[~2010-11-13  3:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-13  3:24 troll [this message]
2010-11-13 10:24 ` tagged primitive operation and freezing Ludovic Brenta
2010-11-15 14:23   ` troll
2010-11-15 16:30     ` Adam Beneschan
2010-11-16  8:53       ` Ludovic Brenta
replies disabled

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