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,772ae8afc5db35f2 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Can't export object of private type Date: 1999/03/01 Message-ID: #1/1 X-Deja-AN: 449706796 Sender: matt@mheaney.ni.net References: <7b6nqe$75m$1@remarQ.com> NNTP-Posting-Date: Sun, 28 Feb 1999 17:33:31 PDT Newsgroups: comp.lang.ada Date: 1999-03-01T00:00:00+00:00 List-Id: nospam@thanks.com.au (Don Harrison) writes: > That view seems to be widely held in Ada circles. However, I can't help > noticing that purity very neatly deals with the singleton issue (.. and a > number of other Ada problems). :) I think the "problem" is that the proper idioms for implementing singleton abstractions in Ada aren't well-known. The articles I've been submitting to the ACM patterns archive are an attempt to overcome this. As I explained in my previous posts in this thread, a polymorphic singleton can be implemented in Ada by using a tagged, limited, and indefinite type, and declaring an instance of that type in the package body. The singleton package exports a function that returns a pointer to that object (if you need an object) or just returns the object (if you need a value). declare Singleton : Singleton_Type'Class renames Ref.all; begin end; This is how you implement Eiffel's once-functions in Ada95. Note that the languages have made different decisions here: Eiffel moved once-functions directly into the language, while Ada95 gives you the primitives for assembling them yourself.