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,e92d558e5b77fce2,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.74.201 with SMTP id w9mr4630866pbv.0.1328479401562; Sun, 05 Feb 2012 14:03:21 -0800 (PST) Path: lh20ni264567pbb.0!nntp.google.com!news1.google.com!postnews.google.com!l14g2000vbe.googlegroups.com!not-for-mail From: Simon Belmont Newsgroups: comp.lang.ada Subject: Building limited types through nested creator functions Date: Sun, 5 Feb 2012 14:03:21 -0800 (PST) Organization: http://groups.google.com Message-ID: <40048c5a-ecf5-43e6-8c76-a294d0c333d1@l14g2000vbe.googlegroups.com> NNTP-Posting-Host: 24.218.138.255 Mime-Version: 1.0 X-Trace: posting.google.com 1328479401 19483 127.0.0.1 (5 Feb 2012 22:03:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 5 Feb 2012 22:03:21 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l14g2000vbe.googlegroups.com; posting-host=24.218.138.255; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; InfoPath.2),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-02-05T14:03:21-08:00 List-Id: Hi, Consider two limited record types, inner and outer, with the former nested inside the latter. If the records are public, then code can initialize the outer by specifying an aggregate for the inner, as in: type Inner is limited record e : Integer; end record; type Outer is limited record i : Inner; end record; o : Outer := Outer'(i => Inner'(e => 42)); However, if types are made private, suitable functions must be provided to make the appropriate objects. If just Inner is private, then this can be done (assuming simple creator functions that just create the objects with the given values): o : Outer := Outer'(i => Make_Inner(arg => 42)); but if both are private, then the following: o : Outer := Make_Outer (arg => Make_Inner(arg => 42)); ends up being illegal, because in the code: function Make_Outer (arg : Inner) return Outer is begin return Outer'(i => arg); end Make_Outer would end up trying to copy a limited type. For the cases in which an existing object is passed in, this would be the appropriate action, but for cases where the object is built-in-place into the argument, clearly the intended behavior is to build it in place to the resultant object. It's easy enough to use an access value, but as unnecessary use of access values is generally discouraged, I was just curious if there was an alternative mechanism to achieve the desired effect. -sb