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

Damien Carbonne <damien.carbonne@free.fr> writes:

> 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);

Yes, that's primitive of T.

>    procedure Class_Wide(Obj : T'Class);

Yes, that's class-wide.

> end P;
> 
> with P; use P;
> package O is
>    procedure What_Is_Its_Category(Obj : T);

That one is not primitive, because it isn't declared in the same package
spec as T.

>    procedure Again_Class_Wide(Obj ; T'Class);

Yes, that's class-wide -- class-wide operations can be declared
anywhere.

> 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)

No, P1 is not primitive (not dispatching) because it is not declared in
the same package spec as Root.  In fact, Root is not declared in a
package spec, so the only primitive ops of Root are "=" and "/=".

You can get more by inheriting them, as I suggested in a previous
message.

> 2) P2 is class-wide.

Yes.

> 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).

I don't think you can, but maybe I misunderstand what you're trying to
do.

- Bob




      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
2000-09-19  0:00     ` Robert A Duff [this message]
replies disabled

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