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,2843c5eea3415584 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: APQ Date: Wed, 22 Dec 2004 10:14:45 +0100 Organization: cbb software GmbH Message-ID: References: <2hju7i5ft73q$.x4md24pt913v.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: individual.net 9IDBImdG6ghtJlCsrWWogQXifcycKECHWbS/RxjWTTpYzhfMw= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:7145 Date: 2004-12-22T10:14:45+01:00 List-Id: On Wed, 22 Dec 2004 10:29:01 +1100, Brian May wrote: >>>>>> "Dmitry" == Dmitry A Kazakov writes: > Dmitry> function Copy (C : Root_Connection_Type) > Dmitry> return Root_Connection_Ptr is abstract; > > Dmitry> This would allocate a copy and connect it to the same > Dmitry> DB. Because reference counting is intended you will need > Dmitry> dynamic allocation anyway. The user will of course do it > Dmitry> all with handles: > > I have a suspicion this would not work as Root_Connection_Type is a > limited type. Or am I yet again mistaken? You probably mean this: function Copy (C : Root_Connection_Type'Class) return Root_Connection_Ptr is begin return new Root_Connection_Type'Class'(C); end Copy; This indeed cannot work for limited types. This was the reason why Copy was declared abstract primitive instead: function Copy (C : Root_Connection_Type) return Root_Connection_Ptr is abstract; It will dispatch to an implementation which knows how to copy itself: function Copy (C : My_Connection_Type) return Root_Connection_Ptr is Result : Root_Connection_Ptr := new My_Connection_Type; Object : My_Connection_Type renames My_Connection_Type (Result.all); begin Object.Field_Foo := C.Field_Foo; ... -- Clone me tender return Result; exception when others => Free (Result); -- No memory leaks! raise; end Copy; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de