From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3b7d2943d4e48cd3 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: generic formal primitive [dispatching] operation Date: 2000/09/19 Message-ID: #1/1 X-Deja-AN: 671830100 Sender: bobduff@world.std.com (Robert A Duff) References: <39C5321E.805A73D1@free.fr> <39C92E15.5EA5FACE@free.fr> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-09-19T00:00:00+00:00 List-Id: Damien Carbonne 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