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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,af92cb4b0cc736af X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-04 07:18:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.204!attbi_feed4!attbi.com!sccrnsc02.POSTED!not-for-mail Message-ID: <3DC68FB2.1040503@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: problem with abstract types References: <3DC12CFF.EC36842C@brighton.ac.uk> <3DC165F9.9000000@attbi.com> <8nmtpa-pd1.ln@uli.uli-eckhardt.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.61.239.24 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc02 1036423090 24.61.239.24 (Mon, 04 Nov 2002 15:18:10 GMT) NNTP-Posting-Date: Mon, 04 Nov 2002 15:18:10 GMT Organization: AT&T Broadband Date: Mon, 04 Nov 2002 15:18:10 GMT Xref: archiver1.google.com comp.lang.ada:30346 Date: 2002-11-04T15:18:10+00:00 List-Id: Robert A Duff wrote: > Right, but if the code can't figure out the Tag of Reg when it is > created, or if the Tag changes over time, then Reg will have to be of > an access-to-Registry'Class type. But that does not imply that all > the operations need to take access parameters. They can take Registry > parameters, and you would then pass Reg.all as the actual parameter. Bob, this is at best overkill in this case. I can imagine a situation where you might want to copy data from one type of registry to another that would require having two open registries with different tags. But even in that case, you have as an invariant that every object of type registry has a single tag value, and it must be determinable when the registry is opened. Open registries morphing their types underneath a program boggles the mind. I guess that there is a meta-rule here. To paraphrase Einstein, "The user view of a data structure should be as simple as possible, but no simpler." ;-) The "extra" work the implementor of an abstraction may have to accept to keep the visible abstraction simple is just good software engineering. Ada goes to a lot of hard work to allow simple abstractions to be implemented with little or no run-time overhead. In this particular case, the compiler might generate better code for the case with a classwide variable initialized at open than for an access to classwide type varible. But I don't see that "savings" as the real reason for implementing an abstraction correctly. The real benefit is that the user of the abstraction doesn't have to sweat the details if the abstraction is a good match to "reality," whatever that means to the user of the abstraction. For example, if you are writing avionics software, "this aircraft" is an implicit constant. Some of its attributes, such as weight or current airspeed may change, but avionics software does not expect to find itself in a new aircraft during flight. If you are working on air traffic control software, "this aircraft" is a variable, and in fact, you even have to change the type of aircraft associated with a particular track. (Mostly from unknown to a particular class, but that is a detail.)