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-Thread: 103376,901038687c38f61c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Idiom for a class and an object in Ada References: From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 22 Oct 2004 01:36:29 GMT NNTP-Posting-Host: 64.185.133.124 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1098408989 64.185.133.124 (Thu, 21 Oct 2004 18:36:29 PDT) NNTP-Posting-Date: Thu, 21 Oct 2004 18:36:29 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:5611 Date: 2004-10-22T01:36:29+00:00 List-Id: Jeffrey Carter writes: > Ignoring the absence of any requirement that the objects be created > dynamically, there are several ways: > > declare > Instance : T renames Make (...); > begin We appear to be comparing apples and oranges. The technique you show above will only work (assuming the full of the type is limited) if the object is allocated statically. You obviously cannot use a function to return an object whose type is limited (the full view, anyway), if the object is dynamically allocated on the stack. (Try it and see.) My example was only intended to illustrate the technique of using a factory function to allocate instances. The indirection allows the package to hide the decision about whether instances are allocated statically (e.g. the flyweight pattern) or dynamically. -Matt BTW: It's H-E-A-N-E-Y, like the poet.