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 Path: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.snarked.org!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Elaboration order handling (Was: Bug in 'gnatmake') Date: Wed, 19 Jun 2013 12:41:46 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: 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> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1371660138 10785 192.74.137.71 (19 Jun 2013 16:42:18 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 19 Jun 2013 16:42:18 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:EJOD5VN8f3mDnLgIcteC66yifE0= X-Original-Bytes: 3869 Xref: number.nntp.dca.giganews.com comp.lang.ada:181978 Date: 2013-06-19T12:41:46-04:00 List-Id: Adam Beneschan writes: > On Wednesday, June 19, 2013 5:22:30 AM UTC-7, Robert A Duff wrote: > >> Lexicographic order would work. Or backwards of that. Or apply >> "rot-13" to the bytes and then do lexicographic order. ;-) > > I guess it could work, but I gotta tell you--that seems really weird. > I've never heard of another language where the semantics could depend > on the lexicographical order of the identifiers. Well, the GNAT dialect of Ada does just that! Is it weird to have it in the Ada RM, but not so weird to have it in the GNAT RM? Yes, it's kind of weird to use that order, but there's no other order that's any less weird. What we want is an arbitrary order that is the same for all compilers. "Arbitrary" in the sense that we don't care what the order is, and we don't deliberately write code that depends on it. >> Or you could base it on the order in which 'with' clauses >> happen to appear. > > No, I don't think that would work. Say there are two packages, Pack1 > and Pack2, that get included in the program, and there is no rule (in > the current language) that specifies which one gets elaborated first. The with clauses (and parent/child relationships and so forth) form a directed graph. You can define an order in which to walk it however you like, so long as it's deterministic. You could say, start at the main procedure spec. Walk all of the with'ed specs, in the order mentioned. Walk the corresponding body. ("Walk" is recursive, of course. And as usual for graph walks, you keep track of which nodes have been visited, and if you run across an already-visited node, do nothing.) This visits all the library items in a well-defined order, and if all compilers were required to use that algorithm, it would be a portable order. Then you say that whenever the current Ada rules allow multiple orders, you must choose the order from the above graph-walking algorithm. > Adding a rule based on the "with" clause order would work if Pack1 and > Pack2 are both with'ed by the same package, Pack3, and are not with'ed > anywhere else. But other than that one narrow case, I don't see how > you could write a rule to base elaboration order on "with" clause > order. If Pack1 and Pack2 are with-ed elsewhere (than Pack3), then either that "elsewhere" comes before or after Pack3 in the walk (or some of each). Whichever 'with Pack1' you run across first in the walk is the one that determines where Pack1 occurs in the order. - Bob