From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,688b25ba856f42d7 X-Google-Attributes: gid103376,public From: "Jeff Creem" Subject: Re: question about functions (bis) Date: 2000/01/21 Message-ID: <869nk6$oc2$1@pyrite.mv.net>#1/1 X-Deja-AN: 575710431 References: <8690s0$8tq$1@news.mgn.net> <38883285.AB6ED64C@gecm.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@mv.com X-Trace: pyrite.mv.net 948462022 24962 199.125.99.23 (21 Jan 2000 13:40:22 GMT) Organization: MV Communications, Inc. X-MSMail-Priority: Normal NNTP-Posting-Date: 21 Jan 2000 13:40:22 GMT Newsgroups: comp.lang.ada Date: 2000-01-21T13:40:22+00:00 List-Id: Philip Anderson 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