comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeff Creem" <jcreem@atetola.mv.com>
Subject: Re: question about functions (bis)
Date: 2000/01/21
Date: 2000-01-21T13:40:22+00:00	[thread overview]
Message-ID: <869nk6$oc2$1@pyrite.mv.net> (raw)
In-Reply-To: 38883285.AB6ED64C@gecm.com


Philip Anderson <phil.anderson@gecm.com> wrote in message
news:38883285.AB6ED64C@gecm.com...
> Pascal LEJEUNE wrote:
> >
> > function ADD (A, B : in T) return T is
> >    tmp : system.address;
> > begin
> >    << find the address of the result (that's my problem !!) >> and
> >    put it in a local variable (tmp)
> >
> >    call a procedure which use directly the hardware :
> >    proc (a'address, b'address, tmp);
> > end ADD;
> >
> > So, the problem is quite simple : the type T is a "numerical" type
> > on which it is normal to have operators ... but the hardware need
> > to have the address of the arguments and the address of the result !!!
>
>
> Can't you simply write:
>
> function ADD (A, B : in T) return T is
>    tmp : T;
> begin
>    -- call a procedure which directly uses the hardware :
>    --
>    proc (a'address, b'address, tmp'address);
>    return tmp;
> end ADD;
>



Which by the way when you do this, in certain cases, GNAT actually does not
even really create a new
variable tmp. In certain instances tmp is optimized out and 'address tmp =
'address of location of return
value.

(At least it looked that way to me compiling some test code on x86 and
looking at resulting code)
Jeff Creem







  reply	other threads:[~2000-01-21  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-21  0:00 question about functions (bis) Pascal LEJEUNE
2000-01-21  0:00 ` Philip Anderson
2000-01-21  0:00   ` Jeff Creem [this message]
2000-01-21  0:00 ` David C. Hoos, Sr.
2000-01-24  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