comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Elaboration order handling (Was: Bug in 'gnatmake')
Date: Wed, 19 Jun 2013 08:22:30 -0400
Date: 2013-06-19T08:22:30-04:00	[thread overview]
Message-ID: <wccip1acmt5.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: db04ccb2-a3f7-4daa-8846-df9a992a0f85@googlegroups.com

Adam Beneschan <adam@irvine.com> writes:

> On Tuesday, June 18, 2013 10:09:21 AM UTC-7, Robert A Duff wrote:
>
>> It is certainly a big language-design flaw that the elab order is
>> implementation defined.  Ada code tends to be pretty portable for the
>> most part, but elab order is one of the top issues that cause
>> non-portability.  That and overuse of representation clauses.
>
> Yeah, but if they had decided to specify the order instead of leaving
> it implementation-defined, what order could they have chosen?
> Alphabetical?

Lexicographic order would work.  Or backwards of that.  Or apply
"rot-13" to the bytes and then do lexicographic order.  ;-)

Or you could base it on the order in which 'with' clauses
happen to appear.

Programmers shouldn't be depending on lexicographic (or whatever) order,
but if they do so by accident, it's best that their program still works
10 years later when it is ported (probably by a different set of
programmers).

>...(Think about what joy that would have caused the ARG
> when Unicode support was added to the language!!!)  I think the
> problem is that, unlike some cases (like subprogram parameters, where
> the language designers *could* have specified left-to-right evaluation
> instead of implementation-defined order), there's no natural ordering
> of library packages in a program.

There's no reason the order has to be "natural".  I'm just saying it
should be the same on all implementations.

The situation with parameters is different:  Allowing the compiler to
choose any order has a disadvantage (portability problems) and an
advantage (efficiency).  There's a tradeoff.  I happen to think
they made the wrong choice, but reasonable people can disagree
on that point.

But with elab order, there is exactly ZERO benefit to allowing
arbitrary orders.  And the disadvantage is huge:  I've seen people
wasting boatloads of money on this!

>...So I don't even see the beginning
> of a solution.

I don't see what the big deal is.  Any legal Ada identifier can be
represented as a Wide_Wide_String, and every Ada 2012 implementation
supports the "<" operator on those.  So one trivial solution is to
simply sort based on that "<", in cases where the current rules about
'with' clauses and pragmas leave the order undefined.

Another solution just occurred to me:  Require the programmer
to put in enough pragmas Elaborate_All (etc) that there is only
one possible order.  Probably not a good idea, but it would
solve the portability problem.

- Bob


  parent reply	other threads:[~2013-06-19 12:22 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-17 10:57 Range check for type 'Integer' Peter Brooks
2013-06-17 11:23 ` Simon Clubley
2013-06-17 11:54   ` Simon Wright
2013-06-17 12:55   ` Peter Brooks
2013-06-17 13:28     ` Shark8
2013-06-17 13:45       ` Peter Brooks
2013-06-17 21:16         ` Shark8
2013-06-18 10:48     ` Stephen Leake
2013-06-17 12:46 ` Dmitry A. Kazakov
2013-06-17 13:23 ` Bug in 'gnatmake' (Was: Range check for type 'Integer') Jacob Sparre Andersen
2013-06-17 13:32   ` Bug in 'gnatmake' Jacob Sparre Andersen
2013-06-17 16:50   ` Bug in 'gnatmake' (Was: Range check for type 'Integer') Robert A Duff
2013-06-17 19:15     ` Peter Brooks
2013-06-17 21:09       ` Shark8
2013-06-17 21:22       ` Jeffrey Carter
2013-06-18  1:21         ` Peter Brooks
2013-06-18  6:33           ` Jeffrey Carter
2013-06-18  7:29       ` Georg Bauhaus
2013-06-17 18:49   ` Bug in 'gnatmake' Simon Wright
2013-06-18  9:09     ` Elaboration order handling (Was: Bug in 'gnatmake') Jacob Sparre Andersen
2013-06-18 17:09       ` Robert A Duff
2013-06-18 22:52         ` Adam Beneschan
2013-06-19  1:21           ` Jeffrey Carter
2013-06-19 12:38             ` Robert A Duff
2013-06-19 20:43               ` Georg Bauhaus
2013-06-20  0:37                 ` Robert A Duff
2013-06-20 19:56                   ` Georg Bauhaus
2013-06-19 12:22           ` Robert A Duff [this message]
2013-06-19 15:46             ` Adam Beneschan
2013-06-19 16:41               ` Robert A Duff
2013-06-19 20:47               ` Georg Bauhaus
2013-06-19 21:36                 ` Adam Beneschan
2013-06-20  0:57                 ` Robert A Duff
2013-06-20  1:09                   ` Jeffrey Carter
2013-06-20  2:29                     ` Adam Beneschan
2013-06-20  6:08                       ` Jeffrey Carter
2013-06-20 15:11                     ` Robert A Duff
2013-06-21  5:26                       ` Jeffrey Carter
2013-06-21 15:48                         ` Adam Beneschan
2013-06-21 18:35                           ` Jeffrey Carter
2013-06-21 19:10                             ` Robert A Duff
2013-06-21 21:27                               ` Jeffrey Carter
2013-06-21 20:43                             ` Adam Beneschan
2013-06-21 21:44                               ` Jeffrey Carter
2013-06-21 23:47                                 ` Robert A Duff
2013-06-23 14:43                                   ` AdaMagica
2013-06-21 18:58                         ` null declarative parts (was: Re: Elaboration order handling) Robert A Duff
2013-06-21 20:42                           ` null declarative parts Georg Bauhaus
2013-06-20  2:11                   ` Elaboration order handling (Was: Bug in 'gnatmake') Adam Beneschan
2013-06-20 14:44                     ` Robert A Duff
2013-06-20 11:24                   ` G.B.
2013-06-20 15:23                     ` Robert A Duff
2013-06-19 21:00             ` Georg Bauhaus
2013-06-19 22:26             ` Randy Brukardt
2013-06-20  0:31               ` Robert A Duff
2013-06-20 21:36                 ` Randy Brukardt
2013-06-19 13:07         ` Bill Findlay
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox