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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: nospam@thanks.com.au (Don Harrison) Subject: Re: Can't export object of private type Date: 1999/02/26 Message-ID: #1/1 X-Deja-AN: 448639318 Sender: news@syd.csa.com.au X-Nntp-Posting-Host: dev7 References: <7b4517$2bbr@news3.newsguy.com> Organization: CSC Australia, Sydney Reply-To: nospam@thanks.com.au Newsgroups: comp.lang.ada Date: 1999-02-26T00:00:00+00:00 List-Id: Sam Mize wrote: :Don Harrison wrote: : :> Actually, I don't necessarily want to do that. What I'm really after :> is polymorphic singletons - objects that :> :> 1) Have only one instance :> 2) Are polymorphic :> 3) Are visible to clients :> 4) Can be called without a package prefix. :> :> I can acheive two or three, but not all four. :( : :I think I follow what you mean here. : :By "singleton" and (1) you mean that there can exist only one object :of the type. Yes. :But a visible type makes that impossible to ensure, so :the approach you were taking is fatally flawed. Correct. :I would represent each singleton with a package, which gives 1 and 3, :and use programming by extension to get points 2 and 4. [Sam's example] :Does that accomplish what you wanted? Not sure. I'm still digesting it. :) :Let me guess. I bet "singleton" is a common object-oriented term, and :it's usually considered to be a special case of a class. Pretty much. It's where a class has a single instance rather than many. :In Ada terms, it's just a package encapsulating some code and data. We :can use Ada 95's programming-by-extension capability to execute the :right procedure, based on a flag value. This isn't really an :object-oriented concept at all, but many people think polymorphism is :inherently tied up with object orientation. It's true there are different kinds of polymorphism. Ada had at least two before OO was introduced: 1) Coercive (Unchecked_Conversion etc.) 2) Parametric (generics, discriminants). -- Don (Harrison). donh at syd.csa.com.au