comp.lang.ada
 help / color / mirror / Atom feed
From: Damien Carbonne <damien.carbonne@free.fr>
Subject: Re: generic formal primitive [dispatching] operation
Date: 2000/09/19
Date: 2000-09-19T00:00:00+00:00	[thread overview]
Message-ID: <39C92E15.5EA5FACE@free.fr> (raw)
In-Reply-To: wccog1ln229.fsf@world.std.com

Robert A Duff a �crit :

> Damien Carbonne <damien.carbonne@free.fr> writes:
>
> > I would like to create a generic package that has, as formal parameters,
> > a tagged type and some primitive dispatching operations on that type.
>
> Try using a generic formal derived type.  Declare the root type outside
> the generic, with the primitive you want, and then declare a generic
> formal type derived from that.
>

As I explained in my answer to Thomas Quinot, I would like to avoid this
solution, because it is a bit more rigid than what
I expect. But if what I expect is impossible, I will come back to it.

>
> > 1) How is it possible to define a formal primitive operation on a tagged
> > type that is:
> >    a) non dispatching (Root'Class ??)
>
> Primitive = dispatching (for tagged types).  Class-wide types are not
> primitive.
>
> >    b) dispatching
>
> See above.
>
> > 2) In the case of class-wide operations, is there any difference between
> > primitive and non primitive
> >    operations ? (I would say no ?)
>
> A class-wide operation is *not* primitive.
>
> - Bob

Sorry, I thought "primitivity" was only related to declarative region
+ freezing rules.
But it is in fact more restricted.

Is the following example correctly labelled ?
package P is
   type T is tagged null record;
   procedure Primitive(Obj : T);
   procedure Class_Wide(Obj : T'Class);
end P;

with P; use P;
package O is
   procedure What_Is_Its_Category(Obj : T);
   procedure Again_Class_Wide(Obj ; T'Class);
end O;


Can we consider that in the following declarations:
generic
   type Root is tagged private;
   with procedure P1(This : access Root);
   with procedure P2(This : access Root'Class);


1) P1 is primitive (that is dispatching). Root can be derived and P1
redefined. (It seems to be the case in
   the example I put in my answer to T.Quinot)
2) P2 is class-wide.

If this is true, my problem is, how is it possible to make the initial
example work, keeping the same spec (just changing the body).

Thanks for clarifications.

Damien.






  reply	other threads:[~2000-09-19  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <39C5321E.805A73D1@free.fr>
2000-09-18  0:00 ` generic formal primitive [dispatching] operation Thomas Quinot
2000-09-19  0:00   ` Damien Carbonne
2000-09-18  0:00 ` Robert A Duff
2000-09-19  0:00   ` Damien Carbonne [this message]
2000-09-19  0:00     ` Robert A Duff
replies disabled

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