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.2 required=5.0 tests=BAYES_00,FROM_WORDY, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,772ae8afc5db35f2 X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: Can't export object of private type Date: 1999/03/02 Message-ID: <7bhlg2$41s$1@plug.news.pipex.net>#1/1 X-Deja-AN: 450502833 References: <7b1k4h$13k6@news3.newsguy.com> <7b4517$2bbr@news3.newsguy.com> <7be1p0$mjg$4@plug.news.pipex.net> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom) Newsgroups: comp.lang.ada Date: 1999-03-02T00:00:00+00:00 List-Id: Indeed I boobed with the function Ref. Sorry. However, I think (and I may need correction on this ;-), Matthew's formulation is also wrong, and actually more complicated than it needs to be. I don't think there's any need for a function Ref where Matt puts it; all you need is the following: package Planetary is type Planet(<>) is abstract tagged limited private; type Planet_Access is access all Planet'Class; [general planetary primitive operations (all abstract)] private ... end Planetary; package Planetary.Mercury is type Planet_Mercury(<>) is abstract new Planet with private; type Mercury_Access is access all Planet_Mercury'Class; [specifically Mercurial primitive operations (all abstract)] function The_Planet return Mercury_Access; private ... end Planetary.Mercury; -- so on for all the planets Inside the bodies of the planet packages, you would declare a (concrete) type derived from the planet's abstract type, and then declare (and implement) all the promised operations for it. Finally, you would declare an aliased object of this type, and then implement the The_Planet function to simply return a value which refers to this object (using the Access attribute). I'm fairly sure this formulation is actually right (finally). We get there in the end! This method not only leverages the fairly powerful dynamic polymorphism functionality Ada 95 has to offer, but it is also (as a general methodology) flexible in terms of whether a (future) planet is actually a single entity, or a binary system, or a whole chain of asteroids. In the latter cases, you might supply functions The_Planet_1 and The_Planet_2, or parametize the function The_Planet accordingly. You could even supply a function to create new planets, e.g.: type Spacestation(<>) is abstract new Planet with private; function New_Station (Cost: Megadollars) return Spacestation; where the user is able to create an (initialised) object, e.g.: Alpha: Spacestation := New_Station(US_Spare_Cash+Russian_Spare_Cash); ------------------------------------- Nick Roberts -------------------------------------