comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Update-in-place assignment
Date: Fri, 21 Jun 2002 00:35:59 +0200
Date: 2002-06-21T00:35:59+02:00	[thread overview]
Message-ID: <3D1258CF.3F4094DA@nbi.dk> (raw)
In-Reply-To: B936AEC8.1C013%bill@wfindlay.demon.co.uk

Bill Findlay wrote:

> There is a case to be made for being able to specify that a component of an
> expression being assigned is the same as the destination of the assignment.
[...]
> E.g. we might have  i := idem -1;  or i := 1 - idem;
> or even  x := 0.5 * (1.0 + a*idem);

I like this idea, but we should (as Rosen points out) also
look at which opportunities it gives the programmer for
creating the corresponding implementations.

The least ugly construction I can come up with right now is
to allow the use of "idem" on an argument to specify that
even though it is formulated as a function, it is actually
just a procedure where the "idem" argument is "in out".

   function "*" (Left  : idem Matrix;
                 Right : in   Float) return Matrix;

should thus on the implementation side of things correspond
to

   procedure "+" (Left  : in out Matrix;
                  Right : in     Float);

But this doesn't contain any of the beauty of your
suggestion. Maybe it is best to leave it as an exercise for
the compiler to translate the expressions to the optimal
code.

Jacob
-- 
"There is a slight error in the exponent" - quantum vaacum
 mass is 10^35 times the total dark matter mass



  parent reply	other threads:[~2002-06-20 22:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-19 20:57 Update-in-place assignment Bill Findlay
2002-06-19 21:38 ` Hyman Rosen
2002-06-20 22:35 ` Jacob Sparre Andersen [this message]
2002-06-21 18:18   ` 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