comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: Reference vs. copy semantics in passing parameters
Date: 19 Feb 91 02:05:39 GMT	[thread overview]
Message-ID: <2750@sparko.gwu.edu> (raw)
In-Reply-To: 16152@as0c.sei.cmu.edu

In article <16152@as0c.sei.cmu.edu> ae@sei.cmu.edu (Arthur Evans) writes:
>Jim Showalter (jls@yoda.Rational.COM) comments that Ada 9X might permit
>functions to have parameters of mode IN OUT or OUT.
>
>An early draft of the Requirements Document included a requirement for
>such a change.  However, because of many comments opposing the change it
>was removed from the final document.

A good decision, IMHO. A function should be as nearly a "black box" as
possible, which has no side effects. In Ada a function that has state
memory (a pseudo-random number generator, for example), must have a side
effect (of modifying a variable of the package body it's in, presumably).
This could have been prevented if Ada had allowed _static_ data structures
in subprograms, a la PL/1, C, and Fortran. But alas, it doesn't, and I'm
sure it won't.

But in any case, the client of the function should not be able to cause
side effects. Just because other languages have "value-returning procedures"
or "functions with side effects" (dpending on how you want to look at it)
doesn't mean Ada needs to. Let functions be functions.

Mike Feldman

  reply	other threads:[~1991-02-19  2:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-02-11 15:06 ADA Compiling Query Gordon Russell
1991-02-12 19:01 ` Michael Feldman
1991-02-13 21:16 ` Jeff Bartlett
1991-02-14 16:45   ` Michael Feldman
1991-02-15 23:09     ` Jim Showalter
1991-02-17  0:19       ` Reference vs. copy semantics in passing parameters Michael Feldman
1991-02-17 18:54         ` Erland Sommarskog
1991-02-18 18:41           ` Doug Smith
1991-02-18  0:36         ` Jim Showalter
1991-02-18  1:42           ` Michael Feldman
1991-02-18 18:49           ` Arthur Evans
1991-02-19  2:05             ` Michael Feldman [this message]
1991-02-18 13:10         ` madmats
1991-02-19 19:00           ` Robert I. Eachus
1991-05-16 13:51         ` Alex Blakemore
1991-05-17  8:19           ` Matthias Ulrich Neeracher
1991-05-17 13:44           ` Markku Sakkinen
1991-05-28  5:28           ` Kenneth Almquist
1991-02-18 14:33 ` ADA Compiling Query stt
replies disabled

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