From: Gautier <Gautier.deMontmollin@Maths.UniNe.CH>
Subject: Re: C like op= proposal
Date: 1999/08/16
Date: 1999-08-16T00:00:00+00:00 [thread overview]
Message-ID: <37B7D172.DCE02FFA@Maths.UniNe.CH> (raw)
In-Reply-To: Pine.BSF.4.10.9908152124300.7953-100000@shell5.ba.best.com
> It's certainly not any more than syntactic sugar, but if I were designing
> my own Ada like language from scratch, would it be worth including
> such a facility?
Into the language I think it would be an overload. But there
are situation where there is not
a:= a + 1;
or
a:= a + b;
which is at the same time more readble than the "++"s macro-assembler
counterparts _and_ transformed into "++"s by optimizers, _but_
a(b(c,d+e(f,g)).h(i,j)) := a(b(c,d+e(f,g)).h(i,j)) + 1;
which can be horribily long and unlikely to be catched by
the optimizer -> 2x too slow (at least: the extra code makes
a penalty for processor cache).
I these cases there are some solutions:
- A "renames". But you have to make a declare..begin..end block each time :-(
- Inlined procedures "Inc", "Add" etc. This is much better...
Both solutions may produce code near to a "a(b(c,d+e(f,g)).h(i,j))++" but
it has to be verified.
I'm using a generic Add_Inc package - but I'm sure that a standard
Ada.* equivalent with "intrinsic" pragmas would be the best solution!
generic
type pm_elt is private;
one: pm_elt;
with function "+" (left,right:pm_elt) return pm_elt is <>;
with function "-" (left,right:pm_elt) return pm_elt is <>;
package Add_Inc is
procedure Add(a:in out pm_elt; b:pm_elt);
procedure Sub(a:in out pm_elt; b:pm_elt);
procedure Inc(a:in out pm_elt);
procedure Dec(a:in out pm_elt);
end;
package body Add_Inc is
procedure Add(a:in out pm_elt; b:pm_elt) is begin a:= a+b; end;
procedure Sub(a:in out pm_elt; b:pm_elt) is begin a:= a-b; end;
procedure Inc(a:in out pm_elt) is begin a:=a+one; end;
procedure Dec(a:in out pm_elt) is begin a:=a-one; end;
pragma Inline(Add,Sub,Inc,Dec);
end;
--
Gautier
--------
http://members.xoom.com/gdemont/
next prev parent reply other threads:[~1999-08-16 0:00 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-15 0:00 C like op= proposal Brian Rogoff
1999-08-15 0:00 ` Ray Blaak
1999-08-15 0:00 ` Brian Rogoff
1999-08-16 0:00 ` Gautier [this message]
1999-08-17 0:00 ` Samuel Tardieu
1999-08-17 0:00 ` Gautier
1999-08-17 0:00 ` Andi Kleen
1999-08-18 0:00 ` Robert Dewar
1999-08-17 0:00 ` Brian Rogoff
1999-08-18 0:00 ` Robert Dewar
1999-08-18 0:00 ` Brian Rogoff
1999-08-19 0:00 ` Robert Dewar
1999-08-21 0:00 ` Brian Rogoff
1999-08-23 0:00 ` Robert A Duff
1999-08-18 0:00 ` Ted Dennison
1999-08-18 0:00 ` Jeff Carter
1999-08-18 0:00 ` Keith Thompson
1999-08-19 0:00 ` Michael F. Yoder
1999-08-21 0:00 ` Keith Thompson
1999-08-19 0:00 ` Tarjei T. Jensen
1999-08-19 0:00 ` Ted Dennison
1999-08-19 0:00 ` tmoran
1999-08-19 0:00 ` Lance Kibblewhite
1999-08-19 0:00 ` Robert Dewar
1999-08-20 0:00 ` P.S. Norby
1999-08-21 0:00 ` Robert Dewar
1999-08-18 0:00 ` Robert I. Eachus
1999-08-18 0:00 ` Gautier
1999-08-18 0:00 ` Andi Kleen
1999-08-18 0:00 ` Gautier
1999-08-17 0:00 ` John Duncan
1999-08-17 0:00 ` Gautier
1999-08-16 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox