From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Ada 2012: In-out parameters for functions
Date: Wed, 01 May 2013 21:04:03 +0200
Date: 2013-05-01T21:04:03+02:00 [thread overview]
Message-ID: <op.wwe5w1vgule2fv@cardamome> (raw)
In-Reply-To: 7704abab-86f2-4edc-ad4b-b3d4e70004fb@googlegroups.com
Le Wed, 01 May 2013 18:28:07 +0200, <dptrash@arcor.de> a écrit:
> Why does Ada 2012 have in-out parameters for functions?
>
> Quote from the book 'Ada 2005 Rationale' (page 4): "[..] Indeed many
> other changes were rejected as really unnecessary. These include old
> chestnuts such as in out and out parameters for functions (ugh), [..]".
>
> So, when do I use functions or procedures. Functions have return values.
> Any other differences?
>
> - Dennis
This is just personal opinion, I don't speak for anyone else:
I did not enjoy neither the out mode parameters for functions in Ada 2012,
but after some though, had the conviction it's not that much bad.
On one hand, you were already able to have functions with side effects
prior to Ada 2012, which is even worse than out parameters. If a function
modifies an outer level variable which is visible from its body, and that
variable may be interpreted later from outside of the body of this
function, that's less clear than using an out parameter.
Then, there is what a function do and how it is implemented. Out mode
parameters is just implementation after‑all, and sometime, you may really
need out parameters to complete the purpose of a rally pure function: Ada
function does not returns tuples like SML's functions may do, and to
achieve this in Ada, you need out parameters, or else you may have to
define multiple types everywhere (if all elements of the tuples have
different types, you do not really need to define a record type for that,
as there is no way to take one element for another).
Semantic is one thing, implementation is another. And if you want
functional programming in Ada, you need out parameters.
In/out (both way) parameters may be another story, and may more suggest
this is a procedure and not a function, but still the same: semantic is
one thing, implementation is another, and there is not always an exact
match of one on the other.
--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
next prev parent reply other threads:[~2013-05-01 19:04 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 16:28 Ada 2012: In-out parameters for functions dptrash
2013-05-01 17:27 ` Shark8
2013-05-01 19:04 ` Yannick Duchêne (Hibou57) [this message]
2013-05-01 19:37 ` Dmitry A. Kazakov
2013-05-01 19:58 ` Yannick Duchêne (Hibou57)
2013-05-02 6:41 ` Dmitry A. Kazakov
2013-05-02 7:11 ` Yannick Duchêne (Hibou57)
2013-05-01 23:37 ` Peter C. Chapin
2013-05-03 10:48 ` anon
2013-05-03 11:04 ` Simon Clubley
2013-05-03 11:32 ` Simon Wright
2013-05-03 11:42 ` Yannick Duchêne (Hibou57)
2013-05-03 11:54 ` Yannick Duchêne (Hibou57)
2013-05-03 23:29 ` Randy Brukardt
2013-05-04 1:02 ` Adam Beneschan
2013-05-05 5:16 ` Randy Brukardt
2013-05-05 10:24 ` Niklas Holsti
2013-05-05 11:11 ` Yannick Duchêne (Hibou57)
2013-05-05 12:52 ` Bill Findlay
2013-05-05 15:09 ` Niklas Holsti
2013-05-05 19:23 ` Yannick Duchêne (Hibou57)
2013-05-05 20:37 ` Niklas Holsti
2013-05-07 0:30 ` Randy Brukardt
2013-05-07 2:36 ` Yannick Duchêne (Hibou57)
2013-05-05 19:45 ` Yannick Duchêne (Hibou57)
2013-05-06 15:40 ` Adam Beneschan
2013-05-06 16:17 ` Bill Findlay
2013-05-06 16:47 ` Adam Beneschan
2013-05-06 18:43 ` Bill Findlay
2013-05-07 0:07 ` Dennis Lee Bieber
2013-05-07 2:34 ` Yannick Duchêne (Hibou57)
2013-05-07 0:26 ` Randy Brukardt
2013-05-06 15:26 ` Adam Beneschan
2013-05-07 0:36 ` Randy Brukardt
2013-05-07 3:59 ` Yannick Duchêne (Hibou57)
2013-05-07 4:13 ` Yannick Duchêne (Hibou57)
2013-05-07 11:52 ` Yannick Duchêne (Hibou57)
2013-05-03 11:45 ` AdaMagica
2013-05-03 23:54 ` Randy Brukardt
2013-05-04 6:58 ` J-P. Rosen
2013-05-04 7:21 ` Dmitry A. Kazakov
2013-05-04 17:58 ` J-P. Rosen
2013-05-04 7:40 ` Yannick Duchêne (Hibou57)
2013-05-04 8:05 ` Simon Wright
2013-05-04 17:55 ` J-P. Rosen
2013-05-04 0:40 ` Keith Thompson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox