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 Path: border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Implicit dereferences rational question Date: Wed, 21 May 2014 09:36:10 +0200 Organization: cbb software GmbH Message-ID: <1kghhevnfzyx4$.1juie06nqyink.dlg@40tude.net> References: <1pkkrdwu7lh6y.7cjyncdfw33e.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: QTaafVZuunHujkJPndFR7g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 3225 Xref: number.nntp.dca.giganews.com comp.lang.ada:186536 Date: 2014-05-21T09:36:10+02:00 List-Id: On Tue, 20 May 2014 16:26:08 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:1pkkrdwu7lh6y.7cjyncdfw33e.dlg@40tude.net... >> On Mon, 19 May 2014 16:51:56 -0500, Randy Brukardt wrote: >> >>> "Victor Porton" wrote in message >>> news:llb1aa$gth$1@speranza.aioe.org... >>>> Robert A Duff wrote: >>>>> Victor Porton writes: >>>>> >>>>>> Why implicit dereferences use only access discriminants, not arbitrary >>>>>> access fields? >>>>> >>>>> It helps prevent dangling pointers. >>>> >>>> In which way limiting to discriminants may prevent dangling pointers? >>> >>> Discriminants have a lengthy set of accessibility rules, which turn out >>> to >>> be exactly what's needed for limiting dangling pointers. In particular, >>> it's >>> almost never the case that one can make a copy of an access discriminant, >>> while that's easy for a "arbitrary access field". >> >> Except that dereference, be it implicit or explicit, does not create >> pointers. Obviously, it eliminates a pointer, as the name suggests. > > I suppose, but you have to have a pointer or something very similar to a > pointer if you want to be able to write to it. Actually not. Most pointers and pointer-like objects are initialized once and never change. But this still has nothing to do with implicit dereference, or more precisely with delegation of operations through composition with X.all. > And that's the key feature > here: that one can use these as variables as well as constants. It didn't > make much sense to invent a new, almost pointer construct just for this > purpose when we already had one with the correct semantics. Of course it does. So many projects and practically all bindings require smart pointers, handles and other user-defined referential objects in some or other form. It is about language design principles. Programmers want to control the semantics of referential types. Ada tried to enforce a certain semantics on them in the ugly form of incomprehensible accessibility rules. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de