comp.lang.ada
 help / color / mirror / Atom feed
From: "Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net>
Subject: Re: ML-like alternatives to out parameters for functions
Date: Tue, 01 Apr 2003 14:51:06 GMT
Date: 2003-04-01T14:51:06+00:00	[thread overview]
Message-ID: <uHhia.20028$_14.10457@nwrdny02.gnilink.net> (raw)
In-Reply-To: 3E890A20.8080108@attbi.com

"Robert I. Eachus" <rieachus@attbi.com> wrote in message
news:3E890A20.8080108@attbi.com...
> Note that this does not mean you cannot write functions in Ada that
> alter their parameters.
>
>     function Random(Gen: in Generator) return Uniformly_Distributed is
>       Local_Gen: Generator;
>       for Local_Gen'Address use Gen'Address;
>     begin...
>
> is perfectly legal Ada.

It may be legal code, but the question arises as to whether this is good
code. In most cases, parameter modes are an aid to both the compiler and the
programmer, telling them when we can assume that an actual parameter could
be altered and when its state will remain the same. In the case of the
Random function, however, the parameter mode is a lie. The function
specification indicates that the Gen parameter is not modified by a call to
Random, even though we all know that it does indeed get modified. This is an
inelegant kludge, and it stands out as a blemish on the predefined packages,
which for the most part are very well designed.





  reply	other threads:[~2003-04-01 14:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-17 22:17 ML-like alternatives to out parameters for functions Mark Lorenzen
2003-03-17 21:47 ` Stephen Leake
2003-03-17 23:34   ` Mark Lorenzen
2003-03-18  3:54     ` John R. Strohm
2003-03-18  8:59     ` Preben Randhol
2003-03-18 21:09     ` tmoran
2003-03-18 17:04   ` Frank J. Lhota
2003-03-18 18:52     ` Mark Lorenzen
2003-03-18 19:16       ` Frank J. Lhota
2003-04-01  3:39         ` Robert I. Eachus
2003-04-01 14:51           ` Frank J. Lhota [this message]
2003-03-18  8:37 ` Dmitry A. Kazakov
2003-03-18  9:07 ` Preben Randhol
2003-03-19  7:31 ` Mark Biggar
  -- strict thread matches above, loose matches on Subject: below --
2003-04-02  0:23 Alexandre E. Kopilovitch
replies disabled

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