comp.lang.ada
 help / color / mirror / Atom feed
From: Jeff Carter <jrcarter@acm.org>
Subject: Re: Access and alias
Date: 2000/04/05
Date: 2000-04-05T00:00:00+00:00	[thread overview]
Message-ID: <38EBBBBE.87C93900@acm.org> (raw)
In-Reply-To: 8cfnpd$3h7$1@nnrp1.deja.com

Ted Dennison wrote:
> 
> In article <38EB55AE.D4A241FD@icn.siemens.de>,
>   Alfred Hilscher <Alfred.Hilscher@icn.siemens.de> wrote:
> > If you write your own bindings, you shouldn't work with 'address. Use
> > an in out parameter instead.
> > E.g. proc (ref : SYSTEM.ADDRESS); --> proc (ref : in out X);
> 
> ...unless you are writing a binding to a function, in which case you are
> back to using addresses.

If you have to pass null, access types (with convention C) work fine. If
you don't have to pass null, in out works for procedures, and access
parameters work for functions. All keep the type checking that addresses
lose:

-- int func (int* I);

function F1 (I : System.Address) return Int;
pragma Import (C, F1, "func");

function F2 (I : access Int) return Int;
pragma Import (C, F2, "func");

I : aliased Int;
J : Int;
S : String := Get;

...

J := F1 (I'Address); -- works as intended
J := F1 (S'Address); -- works as not intended
J := F2 (I'access); -- works as intended
J := F2 (S'access); -- compilation error

-- 
Jeff Carter
"You couldn't catch clap in a brothel, silly English K...niggets."
Monty Python & the Holy Grail




  reply	other threads:[~2000-04-05  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-04  0:00 Access and alias NANCY HEHIR
2000-04-04  0:00 ` Laurent Guerby
2000-04-04  0:00   ` NANCY HEHIR
2000-04-04  0:00     ` Laurent Guerby
2000-04-05  0:00       ` Alfred Hilscher
2000-04-05  0:00         ` Ted Dennison
2000-04-05  0:00           ` Jeff Carter [this message]
2000-04-06  0:00             ` Robert Dewar
2000-04-07  0:00               ` Jeff Carter
2000-04-06  0:00             ` Alfred Hilscher
2000-04-07  0:00               ` Jeff Carter
2000-04-06  0:00           ` tmoran
2000-04-07  0:00             ` Robert Dewar
2000-04-07  0:00               ` tmoran
2000-04-09  0:00                 ` Robert Dewar
2000-04-09  0:00                   ` tmoran
2000-04-10  0:00                 ` Jack W. Sharer
2000-04-06  0:00           ` Robert Dewar
2000-04-05  0:00         ` Laurent Guerby
2000-04-05  0:00     ` Jeffrey D. Cherry
2000-04-04  0:00 ` tmoran
replies disabled

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