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: a07f3367d7,efde8669839c1c0a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!postnews.google.com!l13g2000yqb.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Proper program structure Date: Thu, 1 Oct 2009 00:35:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: <274da2eb-d82f-4751-bc82-2753d0e0ec40@l13g2000yqb.googlegroups.com> References: <638d582c-f275-48a9-aa2a-237f2edd123c@c37g2000yqi.googlegroups.com> <2c37ff49-5419-42db-8d93-675757848082@e4g2000prn.googlegroups.com> NNTP-Posting-Host: 137.138.182.236 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1254382526 19097 127.0.0.1 (1 Oct 2009 07:35:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 1 Oct 2009 07:35:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l13g2000yqb.googlegroups.com; posting-host=137.138.182.236; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8553 Date: 2009-10-01T00:35:25-07:00 List-Id: On 1 Pa=C5=BA, 01:43, Adam Beneschan wrote: > Just for the record, I've had occasion in the past to believe that > this should be allowed: > > =C2=A0 =C2=A0type Car is limited record > =C2=A0 =C2=A0 =C2=A0 Gear_Box : aliased Gear_Box_Type; > =C2=A0 =C2=A0 =C2=A0 Engine =C2=A0 : Engine_Type (Car.Gear_Box'Access); > =C2=A0 =C2=A0... Yes, that was one of my ideas. > 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. If we are at potential language proposals, then my problem would be also solved with some conceptual combination of limited with and private child packages. Imagine that Car's components are defined in their private child packages (Car.Engine, Car.Gear_Box, etc.). These packages are withed by Car. Now, to avoid the cyclic dependency between package and its children, I would need to somehow express that the specification of the child package does not need to see the parent anymore than on the "limited" basis, whereas the body of the child package would still have a choice to see the parent spec completely. To be more exact: with Cars.Engine; -- not possible today with Cars.Gear_Box; package Cars is ... private type Car is record Engine : Engine_Type (Car'Access); Gear_Box : Gear_Box_Type (Car'Access); end record; end Cars; -- now the new magic child spec limited private package Cars.Engine is type Engine_Type (C : access Car) is ... end Cars.Engine; -- and the new magic child body with Cars; -- necessary for a complete view of Cars with Cars.Gear_Box; package body Cars.Engine is procedure Run (E : in out Engine_Type) is begin E.C.all.Gear_Box.Move_This_As_Well; end Run; end Cars.Engine; Note: 1. parent package Cars withs its child package Engine, so that it can use Engine_Type as component of the Car 2. specification of child package Cars.Engine does not see anything more than a limited view on its parent's types, so it can use access to Car 3. body of child package Cars.Engine can see complete parent spec, because it withs Cars explicitly Technically it should be possible to compile everything without cycles. The whole magic comes down to the additional form of childhood, where the child does not fully depend on the parent. In other words, the same trick that is used in Ada2005 to cut cyclic dependencies between peers (limited with) could be also used to cut cyclic dependencies between parents and their children. That would be awesome and would allow me to write Ada in Ada. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com Database Access Library for Ada: www.inspirel.com/soci-ada