Re: left-to-right (was In-Out Parameters for functions)

From: Randy Brukardt (randy_at_rrsoftware.com)
Date: 02/28/04


Date: Fri, 27 Feb 2004 18:12:15 -0600


"Stephen Leake" <Stephe.Leake@nasa.gov> wrote in message
news:mailman.25.1077857933.327.comp.lang.ada@ada-france.org...
> Dmitry A.Kazakov <mailbox@dmitry-kazakov.de> writes:
> > Right, the present situation is not good. But IMO the solution lies in
> > introducing formally pure functions and imposing limitations on use of
> > impure functions (and procedures with results) in expressions.
>
> That's way more work than simply requiring left-to-right, and
> therefore far less likely to happen.

I don't think we could allow the incompatibilities that would occur from
banning side-effects in expressions. But a compiler could give a warning if
it found such an expression or potentially such an expression (function
calls to functions that aren't Pure or Pure_Function). That wouldn't be
incompatible, and it would have the effect of detecting the problem when it
happens.

That seems like the most appropriate solution at this point. It's very
similar to the way compilers warn about uses of uninitialized variables
(another place where Ada chose the "unsafe" option for pragmatic reasons).
One could imagine a compiler switch that turned these warnings into errors,
so that at least disiplined developers could avoid problems. (GNAT can do
this for some warnings, I know.)

                      Randy.