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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6dcdd5b561500c28 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 16 Jan 2009 18:33:41 -0600 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: smart pointer dangerous (no -> operator) Date: Sat, 17 Jan 2009 00:43:17 +0000 Reply-To: brian@shapes.demon.co.uk Message-ID: <6j22n4ll4932l07nqc1c8d5q5rubrj9c3a@4ax.com> References: X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-bYn2pXm4htsUDKY0eOPfMTKeL5m0wStiy6rN3vf1uE1SQZ2KktI9W9oCezL9ZZOJcIfq/MovbwpOS+v!4O7twu/etXWY63Mrl04NAWB1OipAwSy0dDUetIZ78wJnZSwSqN8HllwC49zVPTGPGbByetbzx0Ea!twka X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Xref: g2news2.google.com comp.lang.ada:4374 Date: 2009-01-17T00:43:17+00:00 List-Id: On Fri, 16 Jan 2009 12:09:16 +0100, "Dmitry A. Kazakov" wrote: >1. In Ada 95 I declare the proxy type tagged controlled. The handle is >created through a instantiation in the private part of the generic package >Handle: > > type X_Handle is new Ada.Finalization.Controlled with private; > -- Repeat all operations of the target > procedure Foo (Object : X_Handle); > ... -- and so on >private > package Handles is not Object.Handle (...); -- Instantiation > type X_Handle is new Handles.Handle with null record; > >The implementation of Foo goes as follows: > > procedure Foo (Object : X_Handle) is > begin > Foo (Ptr (Object).all); > end Foo; > >this is extremely tedious, but the best way I know. As an Ada newbie, I've probably lost track of something important, but I can't see a reason not to create a generic procedure, and simply instantiate it for each Foo, which would be slightly less boring if it worked.. I suspect it can't be that simple, but I can't see why. You don't know the type of Ptr (Object).all but can't it be private from the generic's point of view, or is that where a generic falls apart? Whatever the type, there must be a Foo() for it, or the above wouldn't compile. -Brian