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,87557ce53b069315 X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: meaning of "current instance" Date: 1999/11/11 Message-ID: <382b4668_4@news1.prserv.net>#1/1 X-Deja-AN: 547513359 Content-transfer-encoding: 7bit References: <382b0da1_2@news1.prserv.net> Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 11 Nov 1999 22:42:48 GMT, 129.37.62.135 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-11T00:00:00+00:00 List-Id: In article , Robert A Duff wrote: > I think you want T to be limited, or else use 'Unchecked_Access. Yes. (The example code below is limited.) >> Object O2 (like O1) has a component I, which is initialized with the >> "current instance." But what is the type of the "current instance" >> here, passed to Init? > > Um, I guess it's T, but what difference does it make? It's *tag* is > NT'Tag. Inside Init, we have a value of an anonymous > access-to-class-wide. So if Init dispatches, it will dispatch to > an NT operation. Function Init does indeed call a dispatching operation. I was hoping that the tag of the parameter was NT'Tag, and you have confirmed that that should be the tag. However, my compiler (GNAT v3.12p) doesn't dispatch on the NT operation; it calls the operation for T. >> procedure Test_P is >> OT : T; >> ON : NT; >> begin >> Put (OT); >> Put (ON); >> end; > > Seems to me it should print: > > I is 0 > I is 1 That's what I was hoping it would do. But with my compiler, that's not what it does. (The output of my compiler is "I is 0" both times.) > But I don't see what the type of the expression T'Access has to do with > it, so perhaps I'm misunderstanding your question. Perhaps I stated my question incorrectly. I do not care about the type of the expression T'Access. I do care about the type of the object designated by the access object returned by T'Access. I care because I want to call an operation that dispatches on the tag of the designated object: function Init (O : access T'Class) return Integer is begin return Do_Init (O); end; where Do_Init is a (private) primitive operation: function Do_Init (O : access T) return Integer; For object O1 (of type T), I want T's Do_Init to be called. For object O2 (of type NT), I want NT's Do_Init to be called. My compiler calls T's Do_Init for both O1 and O2. -- It is impossible to feel great confidence in a negative theory which has always rested its main support on the weak points of its opponent. Joseph Needham, "A Mechanistic Criticism of Vitalism"