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!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Idiom for a class and an object in Ada Date: Thu, 21 Oct 2004 09:51:16 +0200 Message-ID: <1dljnq136n1j1.2oxluar9ofho.dlg@40tude.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de S8AyJL4pvC0MiskeuMP6JQaXNLyqphnQ1pRimDBLHbqJIsjJE= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:5563 Date: 2004-10-21T09:51:16+02:00 List-Id: On Thu, 21 Oct 2004 01:46:39 GMT, Matthew Heaney wrote: > Jeffrey Carter writes: >> And this is why C++ is never a good guide to how to do things in >> Ada. The pointer may well be needed in C++; it's not needed in Ada. > > I don't understand this comment. How else do you dynamically create > instances of T? Why should they be created dynamically (heap)? Heap vs. stack is a matter of object's scope. It should have little or no impact on the design of the type. If it has then probably because of language deficiency, as in C++, or, yes, in Ada where there was no way to initialize limited objects. That will be corrected soon, I hope. For Marin's case the objects are not dynamic. So if read-only objects would suffice, one can just use functions returning limited objects: package Limited_Object is type X (<>) is limited private; function O1 return X; -- No pointer needed ... package body Limited_Object is O1_Value : X; function O1 return X is begin return O1_Value; -- This is OK, O1_Value is never out of scope end O1; ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de