Re: memory management in Ada: tedious without GC?
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Sun, 25 May 2008 10:12:20 +0200
On Sat, 24 May 2008 16:52:03 -0400, Robert A Duff wrote:
"Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> 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
.
- Follow-Ups:
- Re: memory management in Ada: tedious without GC?
- From: Robert A Duff
- Re: memory management in Ada: tedious without GC?
- From: Maciej Sobczak
- Re: memory management in Ada: tedious without GC?
- References:
- memory management in Ada: tedious without GC?
- From: jhc0033@xxxxxxxxx
- Re: memory management in Ada: tedious without GC?
- From: Maciej Sobczak
- Re: memory management in Ada: tedious without GC?
- From: Matthew Heaney
- Re: memory management in Ada: tedious without GC?
- From: Dmitry A. Kazakov
- Re: memory management in Ada: tedious without GC?
- From: Robert A Duff
- Re: memory management in Ada: tedious without GC?
- From: Dmitry A. Kazakov
- Re: memory management in Ada: tedious without GC?
- From: Robert A Duff
- Re: memory management in Ada: tedious without GC?
- From: Dmitry A. Kazakov
- Re: memory management in Ada: tedious without GC?
- From: Robert A Duff
- memory management in Ada: tedious without GC?
- Prev by Date: Re: How Would a Hobbyist Learn Ada?
- Next by Date: Re: memory management in Ada: tedious without GC?
- Previous by thread: Re: memory management in Ada: tedious without GC?
- Next by thread: Re: memory management in Ada: tedious without GC?
- Index(es):
Relevant Pages
|