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: a07f3367d7,efde8669839c1c0a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!e4g2000prn.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Proper program structure Date: Wed, 30 Sep 2009 16:43:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2c37ff49-5419-42db-8d93-675757848082@e4g2000prn.googlegroups.com> References: <638d582c-f275-48a9-aa2a-237f2edd123c@c37g2000yqi.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1254354187 15677 127.0.0.1 (30 Sep 2009 23:43:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 30 Sep 2009 23:43:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e4g2000prn.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8548 Date: 2009-09-30T16:43:07-07:00 List-Id: On Sep 30, 2:25=A0pm, Maciej Sobczak wrote: > 2. Defining them in non-child packages means that they cannot see the > complete structure of the Car and therefore they cannot be "wired" by > discriminants like here: > > =A0 =A0-- wrong: > =A0 =A0type Car is limited record > =A0 =A0 =A0 Body : Body_Type (Car'Access); > =A0 =A0 =A0 Engine : Engire_Type (Car'Access); > =A0 =A0 =A0 -- and so on > > 3. So they have to be wired individually, but discriminants will still > not work, as sibling components of the same record cannot be used to > constrain each other: > > =A0 =A0-- wrong: > =A0 =A0type Car is limited record > =A0 =A0 =A0 Gear_Box : aliased Gear_Box_Type; > =A0 =A0 =A0 Engine : Engire_Type (Gear_Box'Access); > =A0 =A0 =A0 -- and so on Just for the record, I've had occasion in the past to believe that this should be allowed: type Car is limited record Gear_Box : aliased Gear_Box_Type; Engine : Engine_Type (Car.Gear_Box'Access); ... The syntax is slightly different from what you're looking for, but it's more consistent with the current Ada rules since I think there's nowhere else in the language (besides record rep clauses) where a record component can be reference without some sort of prefix selector, but there's already a facility for self-references to types. The only reason this is illegal is because of 3.8(13), which limits the use of a type self-reference in a constraint to T'Access or T'Unchecked_Access, which must appear by itself. This limitation is partly because allowing certain other uses of type self-references would cause problems, and partly to avoid some unnecessary complexities in compilers if arbitrary expressions were allowed. But I think this could be relaxed a bit to allow T.component [.component...]'Access, with some restrictions. As long as this were restricted so that the 'Access value would always be a constant offset from the beginning of the record in a typical compiler, I don't think this would add much complexity, and it would solve some problems, such as yours (I presume---I haven't studied it too closely), and a program I've seen earlier which would have been more straightforward if this feature were allowed but instead had to resort to something a bit tricky. Anyway, maybe this will motivate me to take a second look at that earlier program and perhaps submit a proposal for a new language feature. Offhand, I think the attribute may have to be 'Unchecked_Access to get around accessibility level rules, but I don't recall. -- Adam