comp.lang.ada
 help / color / mirror / Atom feed
From: gautier_niouzes@hotmail.com (Gautier)
Subject: Re: Ada style of passing 'in' parameters considered dangerous?
Date: 11 Feb 2003 00:39:54 -0800
Date: 2003-02-11T08:39:55+00:00	[thread overview]
Message-ID: <17cd177c.0302110039.7f2df760@posting.google.com> (raw)
In-Reply-To: 0th1a.41024$zF6.2804045@bgtnsc04-news.ops.worldnet.att.net

James S. Rogers

> 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.

As Robert metioned, you can: an IN parameter and an IN OUT may
reference the same object. In this situation, ypeee: you believe
that your IN parameter is like a rock-solid, unalterable constant,
but in fact it is being peacefully modified in the procedure itself!

> I have never seen a case where Ada parameter modes have
> shot the programmer in the foot.

I have seen a case of translation (from Modula) where a lot
of procedures were behaving wrong because of the above problem.
Passed-by-copy parameters were translated into "in" parameters,
so their eventual direct modifications were detected at compile-time,
and an explicit copy was added (e.g. procedure P(a:T) is aa:T:= a; ...).
But there were cases with "Q(a,b:T; c:in out T);" and calls like
"Q(a,b,a)". :-) Not a warning from any compiler!
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



  parent reply	other threads:[~2003-02-11  8:39 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
2003-02-11  8:39   ` Gautier [this message]
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