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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.86.200 with SMTP id t8mr5939670qal.0.1371695389328; Wed, 19 Jun 2013 19:29:49 -0700 (PDT) X-Received: by 10.50.73.170 with SMTP id m10mr37528igv.1.1371695389285; Wed, 19 Jun 2013 19:29:49 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!j2no901650qak.0!news-out.google.com!y6ni3510qax.0!nntp.google.com!j2no901645qak.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 19 Jun 2013 19:29:48 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <7f33982d-3bcf-452e-a3b3-3a0a28505ff1@x20g2000vbe.googlegroups.com> <87r4g0g9c0.fsf@adaheads.sparre-andersen.dk> <87ip1bg4z2.fsf_-_@adaheads.sparre-andersen.dk> <53d0b070-a03b-43d0-a560-68dd3a8bebf5@googlegroups.com> <51c218df$0$6623$9b4e6d93@newsspool2.arcor-online.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Elaboration order handling (Was: Bug in 'gnatmake') From: Adam Beneschan Injection-Date: Thu, 20 Jun 2013 02:29:49 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Original-Bytes: 3110 Xref: number.nntp.dca.giganews.com comp.lang.ada:181976 Date: 2013-06-19T19:29:48-07:00 List-Id: On Wednesday, June 19, 2013 6:09:24 PM UTC-7, Jeffrey Carter wrote: > Since we're discussing elaboration order, there's a case that I wonder about: > > with B; > > package A is > function F (I : Integer) return B.Thing; > > function R return Integer; > end A; > > package body A is > function F (I : Integer) return B.Thing is > -- null; > begin -- F > return B.To_Thing (I); > end F; > > function R return Integer is > -- null; > begin -- R > return 7; > end R; > > end A; > > package B is > type Thing is private; > > function To_Thing (I : Integer) return Thing; > private -- B > type Thing is new Integer; > end B; > > with A; > > package body B is > function To_Thing (I : Integer) return Thing is > -- null; > begin -- To_Thing > return Thing (I); > end To_Thing; > > C : constant Integer := A.R; > end B; > > It seems to me there's a valid elaboration order for these: > > * spec of B > * spec of A > * body of A > * body of B > > I've never been able to get such code to bind, though. Is there some way to get > this accepted, or is it illegal Ada? It's legal Ada (and should run without raising Program_Error). It looks like http://docs.adacore.com/gnat-unw-docs/html/gnat_ugn_36.html, especially C.10, discusses this sort of situation, but I don't know if you looked there already. -- Adam