comp.lang.ada
 help / color / mirror / Atom feed
From: Richard Riehle <richard@adaworks.com>
Subject: Re: Ada style of passing 'in' parameters considered dangerous?
Date: Sat, 08 Feb 2003 22:07:38 -0800
Date: 2003-02-09T05:58:29+00:00	[thread overview]
Message-ID: <3E45F02A.497A7DDB@adaworks.com> (raw)
In-Reply-To: wcc3cmyw6t5.fsf@shell01.TheWorld.com

Robert A Duff wrote:

> How about this example:
>
> We have a record representing fractions of whole numbers:
>
>     type Fraction is
>         record
>             Numerator: Integer;
>             Denominator: Positive;
>         end record;
>
>     procedure Reciprocal(Result: out Fraction; X: Fraction);
>     -- Sets Result to the reciprocal of X.
>
>     procedure Reciprocal(Result: out Fraction; X: Fraction) is
>     begin
>         if X.Numerator > 0 then
>             Result.Numerator := X.Denominator;
>             Result.Denominator := X.Numerator;
>         ... etc
>
> It seems reasonable (without seeing the body of Reciprocal) to do:
>
>     Reciprocal(Foo, Foo);

Interesting example.   A little bit of a stretch since it would rarely
occur in practice.  However, it is one reason why I proposed, a few
years ago that we add a mode based on the reserved word constant.
In particular, I would like to be able to use that reserved word
anywhere we normally would be allowed to use access.  Your
example suggests it might be useful under other circumstances
as well.

Richard Riehle




  parent reply	other threads:[~2003-02-09  6:07 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
2003-02-09  2:01 ` Robert A Duff
2003-02-09  2:33   ` Vinzent Hoefler
2003-02-09  6:07   ` Richard Riehle [this message]
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