comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: Finalization and Self Assignment
Date: 2000/02/29
Date: 2000-02-29T00:00:00+00:00	[thread overview]
Message-ID: <wccaekj252t.fsf@world.std.com> (raw)
In-Reply-To: ueTu4.52$kE4.1111@client

"Frank J. Lhota" <lhotaf@lexma.meitech.com> writes:

> - For an assignment_statement that assigns to an object the value of that
> same object, the implementation need not do anything.

If the implementation doesn't take advantage of the above permission,
then it has to use an intermediate temporary variable, so the problem
you're worried about can't happen.  I don't have my RM in front of me,
but I'm sure that's what it says.

> ObjectAda as well as some (all?) versions of GNAT take advantage of this
> permission. I would recommend that this permission be promoted to a
> requirement. In other words, we should require that the compiler NOT do the
> Finalize / Adjust calls when an object is assigned to itself. The issue here
> is not so much efficiency as it is correctness. If we simply eliminate the
> Finalize / Adjust calls from self assignments, these problems go away.

In fact it's probably easier to implement that way (do nothing),
even though it requires a run-time check in general to detect
the self-assignment case.

Now think about array assignment, where they arrays could be overlapping
slices -- you don't know at compile time that they overlap, or even that
they are slices.  The RM allows various implementation strategies here,
too.

- Bob




  reply	other threads:[~2000-02-29  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-29  0:00 Finalization and Self Assignment Frank J. Lhota
2000-02-29  0:00 ` Robert A Duff [this message]
2000-03-04  0:00 ` Simon Wright
2000-03-04  0:00 ` Nick Roberts
replies disabled

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