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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: memory management in Ada: tedious without GC? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> <9f2c2db4-d6c1-4cdf-884c-5cbc26ac7701@d1g2000hsg.googlegroups.com> <1qxcw3pphdlek.1jgsfwb7atdmo.dlg@40tude.net> <10j4zhb9ge8ea.156spz1dkc4vb$.dlg@40tude.net> Date: Sun, 25 May 2008 10:12:20 +0200 Message-ID: <6z9y05h0wes6$.126fz3zrcxvae$.dlg@40tude.net> NNTP-Posting-Date: 25 May 2008 10:12:22 CEST NNTP-Posting-Host: 2df51447.newsspool1.arcor-online.net X-Trace: DXC=kPac\ On Sat, 24 May 2008 16:52:03 -0400, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> Yes, this why it is safe to assume that the program may not rely on it. > > Such assumptions are never safe, because programmers make mistakes. That is why Ada should be picky. I prefer to qualify such programs as erroneous and allow the compiler to reject them. This is independent on whether we would fix the order or not. >> Yes, this is the same dilemma as with re-ordering operands in expressions. > > I don't like the permission to reorder operands, either. > But at least for that, there's a legitimate efficiency concern. > For finalization, I seriously doubt that the permission > to reorder has any significant efficiency benefit. type X is record A : Boolean := False; B : Integer := 1; C : Boolean := False; end record; May the compiler group A and C and initialize both them by zeroing memory? If the initialization order were fixed, that would be illegal to do. >> I understand your argument, but I think that the solution is wrong. I'd >> prefer a better control over the side effects in order to make such >> (erroneous) programs illegal. It is especially important for modern >> pipelined, multi-core architectures. Why not to perform initialization of >> components concurrently? > > Sure, if the compiler can prove there are no side effects, > it can reorder, intersperse, and/or do things in parallel. > In that case, "in declaration order" and "in implementation-defined > order" are equivalent rules. Yes, this could be the ground for a compromise. Let us introduce pure subprograms, not as a pragma Pure, but as a contract. Now, the components are initialized by pure subprograms can be in any order when they are siblings. Others are initialized in their declaration order. > But this is a much bigger change to Ada. The compiler would not need to prove anything. That would be the programmer's responsibility to ensure purity of an implementation. Of course, a decent compiler would make some reasonable checks, but it would be sufficient to verify that pure bodies do not call impure ones. Surely, a pure primitive operation could not be overridden by an impure one, etc. That does not look much intrusive. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de