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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c32fe290813aec20 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: New Ada portable GUI Library? Date: Sun, 20 Jan 2008 17:38:36 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <3LqdnZ0ffYYPeg3anZ2dnUVZ_hudnZ2d@comcast.com> <4790FDC4.6070106@obry.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1200868717 12068 192.74.137.71 (20 Jan 2008 22:38:37 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 20 Jan 2008 22:38:37 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:oq4NFKlRltYFTC+jaXm+W59N6SM= Xref: g2news1.google.com comp.lang.ada:19490 Date: 2008-01-20T17:38:36-05:00 List-Id: Pascal Obry writes: > Robert A Duff a �crit : >> tmoran@acm.org writes: >> >>> Does that mean the designers of Ada's elaboration got it wrong? >> Yes. > > Hum not sure why! Well, there are several problems with Ada's elaboration rules. Perhaps the biggest is that elaboration order is implementation defined. You can have a program that works just fine on one implementation of Ada, but it breaks when you try to port it to another implementation. Fixing the problem is a nightmare, because it's difficult to know where to put the various pragmas (GNAT can help here!), and circularity messages are confusing (in every compiler I've tried!), and every time you add a pragma you have to recompile a whole lot of stuff. There are cases where languages should allow implementations to differ: where there is some efficiency advantage to leaving things ill-defined, or where there is some legitimate need to access hardware or other platform-dependent details. Elaborate order is not such a case! Another problem is that it's too complicated. All those pragmas (Elaborate, Elaborate_All, Preelaborate, Pure, Elaborate_Body, Preelaborable_Initialization, ... -- did I forget any?). Another problem is that it's too restrictive. For example, you can't say: function Make_Symbol(X: String) return Symbol; Empty_Symbol: constant Symbol := Make_Symbol(""); in a package visible part, because of the way elaboration works. Another problem is efficiency: the Ada rules require a run-time check on every call, and it's hard to optimize away those checks in cases involving separate compilation. >... My understanding is that GNAT defaults to something > stricter and more importantly static, fine. But having a dynamic > elaboration that let's you handle more complicated cases does not hurt > to me! The cases where the GNAT default is too restrictive, but the Ada rule (i.e. GNAT's -gnatE switch) is not too restrictive, are rare. I think I've run into such cases approximately twice in the last 10 years. And I think they were related to generics (the problem is that instance bodies are elaborate too early -- it's particularly annoying when the generic body doesn't do anything, which is common). It's a trade-off, but I think the GNAT default improves on the standard Ada model. It doesn't solve all the problems, though. On the other hand, the standard Ada model is better than some languages, where you can't do anything interesting at elaboration time (so you have to complicate your interfaces with Initialize procedures). Or languages that don't bother to detect cycles at all (you can start using data in a class if the class initialization has _started_, not necessarily _finished_). Self-initializing modules is a Good Idea. But Ada got some of the details wrong. - Bob