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,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.13.201 with SMTP id j9mr211099pbc.23.1316277976087; Sat, 17 Sep 2011 09:46:16 -0700 (PDT) Path: m9ni8341pbd.0!nntp.google.com!news1.google.com!postnews.google.com!s20g2000yql.googlegroups.com!not-for-mail From: ytomino Newsgroups: comp.lang.ada Subject: discriminant questions Date: Sat, 17 Sep 2011 09:30:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9f37b726-d80b-4d24-bf3f-28a14255f7fd@s20g2000yql.googlegroups.com> NNTP-Posting-Host: 114.150.108.139 Mime-Version: 1.0 X-Trace: posting.google.com 1316277975 26680 127.0.0.1 (17 Sep 2011 16:46:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 17 Sep 2011 16:46:15 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s20g2000yql.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:18003 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-09-17T09:30:46-07:00 List-Id: Hello, I'm excited at the containers of Ada 2012. I tried to write my code with the style of Ada 2012, and I have some questions. 1) Why is below code error? procedure q1 is generic type e is private; package the_package_like_ada2012_vector is type ref (element : not null access e) is null record; end the_package_like_ada2012_vector; generic type e is private; type ref (element : not null access e) is private; package the_package_use_ref is end the_package_use_ref; package inst1 is new the_package_like_ada2012_vector (integer); package inst2 is new the_package_use_ref (integer, inst1.ref); -- error begin null; end q1; q1.adb:13:65: types of actual discriminants must match formal q1.adb:13:65: instantiation abandoned It seems no way to write a generic algorithm independent of a container. (without Element or Query_Element of Ada 2005 style) 2) Why non-limited types can not have access discriminant with default? procedure q2 is type t1 (value : integer := 100) is null record; -- ok type int_access is access all integer; default : aliased int_access := null; type t2 (element : access int_access := default'access) is null record; -- error begin null; end q2; q2.adb:5:56: (Ada 2005) access discriminants of nonlimited types q2.adb:5:56: cannot have defaults I would like to write smart pointer and make that it is able to assign- able type, as follows: declare a : the_smart_pointer (element => wrap (new Integer'(100))); b : the_smart_pointer (element => wrap (new Integer'(200))); begin a.element.all.all := 300; -- a.all := 300; (if compiler supported Implicit_Dereference) b := a; -- it frees element of b on Finalize and add reference count of a on Assign end; Why is it disallowed? Thank you.