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,ef86287aa487b07a X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: Pb with use of redefined "=" operator Date: 1998/11/10 Message-ID: #1/1 X-Deja-AN: 410464486 Sender: bobduff@world.std.com (Robert A Duff) References: <363F62F3.3FF7@club-internet.fr> <3640B520.D7BEEE72@elca-matrix.ch> <71sc4h$6en$1@nnrp1.dejanews.com> <71tee6$pi5$1@nnrp1.dejanews.com> <729rod$nlv$1@nnrp1.dejanews.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1998-11-10T00:00:00+00:00 List-Id: dennison@telepath.com writes: > My understanding was that without 'Class, the tag may not even be *present* > in the object. It isn't really needed, since every object's type is > determinable at compile time. But when the compiler lays out objects of the type it needs to decide whether to include a tag field. It doesn't know if some other part of the program will mention 'Class (unless it has global knowledge, eg by deferring all code generation to link time). Consider: package P is type T1 is tagged null record; X: T1; procedure Do_Something(X: T1); procedure Do_Something_Else(X: T1); end P; with P; use P; package Q is type T2 is new T1 with null record; Y: T2; procedure Do_Something_Else(X: T2); end Q; with P; use P; with Q; use Q; procedure Main is begin Do_Something(P.X); Do_Something(Q.Y); end Main; package body P is procedure Do_Something(X: T1) is begin Do_Something_Else(T1'Class(X)); <<-------------------- end Do_Something; procedure Do_Something_Else(X: T1) is begin ... end Do_Something_Else; end P; In the usual implementation model, both variables X and Y need a tag field, but we haven't yet seen any 'Class when they are compiled. An alternative is to store tags with parameters and pointers, instead of with the objects themselves. I don't know of any compilers that do that, and I'm not sure it's a good idea -- it seems kind of annoying to double the size of all access-to-classwide types. - Bob -- Change robert to bob to get my real email address. Sorry.