comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: why this construct causes aliasing problem in 2012 with functions allowing In Out?
Date: Thu, 21 Jun 2012 15:06:15 -0500
Date: 2012-06-21T15:06:15-05:00	[thread overview]
Message-ID: <jrvurp$bia$1@munin.nbi.dk> (raw)
In-Reply-To: ikgnsser1io8$.1ofpbj9hcpcio.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:ikgnsser1io8$.1ofpbj9hcpcio.dlg@40tude.net...
...
> Well, there exist possibilities to address the issue.

The issue *is* addressed. Either the slide or the summary of it is wrong.

> Let the language provided means to contract the evaluation order of some
> operations.
>
> Arguments having contracted side effects (like change(...) with its in out
> parameters) would be illegal for any operation having no contracted
> evaluation order, e.g. "-". This would make
>
>   two := change(one,two) + change(one,two)
>
> illegal.

No need to "make it" illegal; it IS illegal.

 But when the order is specified, e.g. left to right for string
> "&", then side effects in arguments would be permitted:
>
>   Name : String := Read (Socket) & Read (Socket);

I don't think the order is specified for "&"; that's the first I've heard of 
it. In any case, this is the actual rule used in Ada 2012 (it only applies 
when the order is unspecified, see the quote I previously posted).

The result is pretty complex, but normally, the compiler will tell you when 
you did something bad; otherwise, it isn't worth much energy to understand.

But this comes back to Adam's point: it wasn't worth trying to make a 
special case for operators that are communative when used alone, so there is 
no exception for "+" or any other case when the result does not actually 
depend on the order (but could have with a different body).

                                    Randy.





  reply	other threads:[~2012-06-21 20:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-20  8:24 why this construct causes aliasing problem in 2012 with functions allowing In Out? Nasser M. Abbasi
2012-06-20  8:26 ` Nasser M. Abbasi
2012-06-20 14:56 ` Adam Beneschan
2012-06-20 15:14   ` Dmitry A. Kazakov
2012-06-21 20:06     ` Randy Brukardt [this message]
2012-06-21 20:00   ` Randy Brukardt
replies disabled

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