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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ab1d177a5a26577d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.50.133 with SMTP id c5mr13115198pbo.2.1318037787550; Fri, 07 Oct 2011 18:36:27 -0700 (PDT) MIME-Version: 1.0 Path: lh7ni13970pbb.0!nntp.google.com!news1.google.com!goblin2!goblin3!goblin.stu.neva.ru!gegeweb.org!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: What's wrong with C++? Date: Fri, 7 Oct 2011 20:36:23 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <1ee1a434-4048-48f6-9f5e-d8126bebb808@r19g2000prm.googlegroups.com> <9f27b2FsgsU1@mid.individual.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1318037786 5008 69.95.181.76 (8 Oct 2011 01:36:26 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 8 Oct 2011 01:36:26 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Xref: news1.google.com comp.lang.ada:18346 Date: 2011-10-07T20:36:23-05:00 List-Id: "Yannick Duch�ne (Hibou57)" wrote in message news:op.v2u8hzeyule2fv@index.ici... >e Wed, 05 Oct 2011 07:13:16 +0200, Niklas Holsti > a �crit: >> Doesn't Ada have a similar theoretical problem with the elaboration >> order? I seem to remember that finding a valid elaboration order for an >> arbitrary Ada program is rather difficult, in general, and compilers are >> allowed to give up on it. >I am not aware enough of the techniques used there, and not a compiler >implementor, but I guess this is a divide-and-conquer strategy. I suppose >this end to be solving a graph route problem, not a Turing complete >language interpretation. > >You raised a good question anyway, I'm curious to know (may be an answer >in some GNAT design papers, or some answers from Randy). I implemented that a long, long time ago, and haven't had to fix anything in it in a long time, so my memory may be wrong, but here's a short explanation: Janus/Ada uses a trial-and-error approach. I figured this was only run once per program, and the number of units involved is usually not that large, so a quadratic algorithm isn't a problem. Essentially, the algorithm checks the entire list of units (parts, spec and bodies are different), with all of the dependencies included, for one all of whose dependencies are already elaborated. As soon as it finds one, it elaborates that, and then starts over from the beginning. If at any point, there is no such unit available, it then gives up trying and produces an error message (the program must not have any consistent elaboration order). The algorithm is complicated by needing to elaborate pure/preelaborated units first, by attempting to keep specs and bodies together when possible, and by elaboration pragmas. These are resolved by having various "soft" dependencies; if no unit can be found that do not violate any of the dependencies, the algorithm tries again looking for units that have all of their hard dependencies loaded. I don't know of any real problem with elaboration given the Ada rules; the usual problem comes when someone tries to change those rules from dynamic to static rules (as GNAT does). Janus/Ada doesn't attempt that. Randy.