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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,28b389d4503cb555 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: generic package dilemma Date: 1999/11/22 Message-ID: <81bt4v$7cr$1@nnrp1.deja.com>#1/1 X-Deja-AN: 551668891 References: <80u48b$ghr$1@bunyip.cc.uq.edu.au> <3832e27f_1@news1.prserv.net> <3832E75D.5B1BA719@mail.com> <383319e8_4@news1.prserv.net> <3833F615.5AD7166C@mail.com> <383442e1_1@news1.prserv.net> <383510EA.9DFEE8B6@mail.com> <383569db_2@news1.prserv.net> <3835CF7A.5604C6A3@mail.com> X-Http-Proxy: 1.0 x43.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Nov 22 17:05:48 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-11-22T00:00:00+00:00 List-Id: In article <3835CF7A.5604C6A3@mail.com>, Mats Weber wrote: > Actually, I have used pragma Elaborate(_All) maybe three times > since 1983. I have always let the compiler figure out an > elaboration order, which turned out to be just fine in almost > all cases with DEC Ada, Verdix and GNAT. I know this approach > is not striclty portable, but I don't care. Well this is a bit like people not caring about seat belts in a car till they have a crash. We have lots of cases of legacy code, particularly Verdix code, where the programmers were, quite unknowingly relying on non-portable behavior. It is very bad programming practice to omit the pragmas (*). In one hard, we had one customer with a large code who spent quite a bit of time running the program and finding out one bug after another of omitted pragma Elaborate's causing Program_Error. The problem is not that VADS is better at finding an elaboration order than GNAT or vice versa, just that they guess differently in situations where there is no one right way of doing things. You can construct cases where GNAT (**) will succeed where Verdix will fail and vice versa. So Mats may have been lucky programming without an Elaborate seat belt so far, but I do not recommend this risky behavior for others! I have seen far too much grief caused by this viewpoint. > and I still think that some minimal automatic elaboration > order generation should be in the language standard (see my > thesis). The story here is that basically we all agreed, but we also agreed that trying to do this in a reasonably upwards compatible manner was far from easy, and there simply was not enough time available in the course of the Ada 95 design. I definitely agree with Mats in general terms, though I do NOT agree with approaches which require building a call tree and tracing actual execution paths through package bodies. Our experience is that the static elaboration approach in GNAT (which was a very large development effort, which is ongoing as we find new aspects, most recently the issue of task bodies for tasks started at elaboration time) works remarkably well, and it is basically simply an automation of the rules about using pragma Elaborate_All. If you ever had to port a GNAT program to another compiler which provided only the old style dynamic elaboration checks, then you could use -gnatwl to tell you where to put the missing pragma Elaborate_All statements. So generally the GNAT implementation attempts precisely to let people program in the way Mats recomends (don't bother about elaboration), and be sure of not running into trouble. Basically, it is a collision avoidance strategy that makes sure you don't need seatbelts :-) (*) It is actually safe to omit the pragmas when using GNAT in its static default elaboration mode, as noted above. (**) This is referring to GNAT running in -gnatE mode which replicates the traditional dynamic elaboration mode. We have to use the -gnatE mode for validation to get through one test whose comments make it clear that it was written (in some sense in horrible style) precisely to undermine any attempts to find an order of elaboration statically :-) Sent via Deja.com http://www.deja.com/ Before you buy.