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,c08a7609345f4e5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Limited use for limited with? Date: Wed, 29 Sep 2010 08:03:38 +0200 Organization: A noiseless patient Spider Message-ID: <8762xpgk79.fsf@ludovic-brenta.org> References: <853314bc-0f79-435f-86a5-d7bcdd610731@c10g2000yqh.googlegroups.com> <36e886fa-b272-461f-bf86-a6b18366b64f@i5g2000yqe.googlegroups.com> <1eug9v5h5mf8d$.ud00hrz48lyr.dlg@40tude.net> <67044906-dacc-4526-b3f6-27e5323ab8fc@n3g2000yqb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Wed, 29 Sep 2010 06:03:38 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="eBx0+2c0tKxsAekRjv8/FA"; logging-data="14192"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+boYvg0PuAp1KM9tFoj8mq" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:4iSoJIc68shW/elOnsxq2bsZ944= sha1:iowzi/ApsbDuaMSXZmxk9duZaF8= Xref: g2news1.google.com comp.lang.ada:14308 Date: 2010-09-29T08:03:38+02:00 List-Id: Maciej Sobczak writes on comp.lang.ada: > Consider: > > procedure Register (X : in Object'Class); > > X will be passed by reference, but there is still nothing in the > signature (apart from the name of the operation) that would suggest > that the reference will be leaked out of the operation's scope. So the > user does this: > > declare > X : My_Concrete_Object; > begin > Register (X); > endl; > > and bang, everything breaks into pieces. No, because this is Ada :) Suppose Register does something like (where Registry is a suitably defined indefinite vector): procedure Register (X : in Object'Class) is begin Registry.Append (X); end Register; This does copy a "hidden" reference to X into the Registry, it copies X itself (i.e. deep copy). So there is no leak and the construct is safe. Not so with explicit access values. -- Ludovic Brenta.