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,70414f56d810c10c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.66.3 with SMTP id b3mr2354016pbt.3.1316476869323; Mon, 19 Sep 2011 17:01:09 -0700 (PDT) MIME-Version: 1.0 Path: lh7ni766pbb.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Mon, 19 Sep 2011 19:01:05 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <9f37b726-d80b-4d24-bf3f-28a14255f7fd@s20g2000yql.googlegroups.com> <86015926-d652-4265-aedd-413312d399f9@dq7g2000vbb.googlegroups.com> <0d272f62-67d0-4905-972c-8a7e912c5531@en1g2000vbb.googlegroups.com> <148cxoyabima2.16mz6xwdph2hj.dlg@40tude.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1316476867 19865 69.95.181.76 (20 Sep 2011 00:01:07 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 20 Sep 2011 00:01:07 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Xref: news1.google.com comp.lang.ada:18037 Date: 2011-09-19T19:01:05-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:148cxoyabima2.16mz6xwdph2hj.dlg@40tude.net... > On Sat, 17 Sep 2011 15:55:15 -0700 (PDT), ytomino wrote: ... >> This code is same as: >> >> type Reference_Type (Element : access Integer) is null record; > > It is not same, and I don't see the purpose of using this construct. In > any > case it cannot serve as a good basis for smart pointers. The "good reason" for using this construct (beyond the obvious one of being able to use the "implicit dereference" construct is one of lifetime. The access discriminant of this object has the same lifetime as the enclosing object; if that object is returned from a function, that is very short. That's important to prevent users from creating dangling pointers to elements stored inside of a container (including a smart pointer container). What we want is for the container to be able to manage the actual objects as it sees fit, so it should not be possible for a user to keep an access to an element for any length of time. We originally had looked at other ways of getting this safety, but eventually it was pointed out that we already had a way to get it with the existing constructs. Thus we simply used those constructs rather than creating more rules and cruft -- the only new things here are the aspects that allow dropping part of the text (the name of the discriminant). We then went a step further and defined indexing operations that allow omitting even more of these calls, making them syntactically look like array indexing. It should be noted that the primary purpose behind all of these things is making the Vector and Map containers easier to use; the others are made consistent but they were not the primary focus. I don't think they help much for the Holders (and we decided not to use them on the unbounded strings because writing would not have worked well). Randy.