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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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.7.66 with SMTP id h2mr640548pba.6.1316300115908; Sat, 17 Sep 2011 15:55:15 -0700 (PDT) Path: m9ni8521pbd.0!nntp.google.com!news1.google.com!postnews.google.com!en1g2000vbb.googlegroups.com!not-for-mail From: ytomino Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Sat, 17 Sep 2011 15:55:15 -0700 (PDT) Organization: http://groups.google.com Message-ID: <0d272f62-67d0-4905-972c-8a7e912c5531@en1g2000vbb.googlegroups.com> References: <9f37b726-d80b-4d24-bf3f-28a14255f7fd@s20g2000yql.googlegroups.com> <86015926-d652-4265-aedd-413312d399f9@dq7g2000vbb.googlegroups.com> NNTP-Posting-Host: 114.150.108.139 Mime-Version: 1.0 X-Trace: posting.google.com 1316300115 29416 127.0.0.1 (17 Sep 2011 22:55:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 17 Sep 2011 22:55:15 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: en1g2000vbb.googlegroups.com; posting-host=114.150.108.139; posting-account=Mi71UQoAAACnFhXo1NVxPlurinchtkIj User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HNKUARELSC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1,gzip(gfe) Xref: news1.google.com comp.lang.ada:18007 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-09-17T15:55:15-07:00 List-Id: >C++ does not have implicit dereferencing at all. Ada has it but only for > attributes, array indexing, component members. C++ has it. struct reference_type { int *element; operator int & () { return *element; } }; This code is same as: type Reference_Type (Element : access Integer) is null record; and replace int * to int ** and int & to int *&, we can use reference_type where raw pointer is required. (In fact, smart pointers in Boost and C++0x have not cast operator but operator * and operator -> . However client codes are same.) Therefore, there is no reason that we could not it with Ada. ...except assignment. Two Ada variables having different discriminant are incompatible and it raise Constraint_Error at runtime. But if default value exists, we can assign these variables. Return to the first question. An access discriminant can not have default value. So I can not make smart pointer like syntax of raw access types after all. I want to know the reason.