comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Ada style of passing 'in' parameters considered dangerous?
Date: Sun, 09 Feb 2003 02:25:45 GMT
Date: 2003-02-09T02:25:45+00:00	[thread overview]
Message-ID: <3E45BC6E.6000701@acm.org> (raw)
In-Reply-To: 0th1a.41024$zF6.2804045@bgtnsc04-news.ops.worldnet.att.net

James S. Rogers wrote:
> 
> In Ada an IN parameter is treated as a constant within the subprogram
> it is passed to. This eliminates the ability to shoot yourself in the foot
> with an IN parameter. An OUT or IN OUT parameter can be passed
> by value or by reference. The language provides no rules about this.
> The difference between the two in Ada is that an OUT parameter
> has no reliable initial value, while an IN OUT parameter does.
> In fact compiler writers are quite reasonable about their chosen
> passing mechanisms. In general, any value larger than a register
> is passed by reference. All other values may be passed by copy
> or by reference.

This is not entirely correct. In Ada, all elementary types are passed by 
copy, regardless of the parameter mode. Elementary types are all numeric 
types, all enumeration types, and all access types.

All limited types and all tagged types are passed by reference, 
regardless of the parameter mode.

The parameter passing mechanism for all other types is not defined by 
the language. Most compilers do a good job of choosing a parameter 
passing mechanism for such types.

Finally, the rules for out-mode parameters provide for many cases in 
which a reliable initial value does exist and the parameter effectively 
has mode in out. This includes all record types that have a component 
with a default initial value.

-- 
Jeff Carter
"Death awaits you all, with nasty, big, pointy teeth!"
Monty Python & the Holy Grail




  parent reply	other threads:[~2003-02-09  2:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-08 22:24 Ada style of passing 'in' parameters considered dangerous? Antti Sykari
2003-02-09  0:41 ` James S. Rogers
2003-02-09  2:11   ` Robert A Duff
2003-02-09  2:25   ` Jeffrey Carter [this message]
2003-02-11  8:39   ` Gautier
2003-02-09  2:01 ` Robert A Duff
2003-02-09  2:33   ` Vinzent Hoefler
2003-02-09  6:07   ` Richard Riehle
2003-02-09  7:13   ` Robert I. Eachus
2003-02-10  4:40     ` Martin Dowie
2003-02-09  2:08 ` Jeffrey Carter
2003-02-10  0:13 ` Leif Holmgren
2003-02-10  9:49 ` Rod Chapman
2003-02-11  9:14 ` Gautier
2003-02-11 13:49   ` Antti Sykari
2003-02-11 17:18   ` Gautier
2003-02-11 17:29     ` Vinzent Hoefler
2003-02-12  1:09   ` Richard Riehle
replies disabled

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