comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ada 2012: In-out parameters for functions
Date: Fri, 3 May 2013 18:54:14 -0500
Date: 2013-05-03T18:54:14-05:00	[thread overview]
Message-ID: <km1in9$kfd$1@munin.nbi.dk> (raw)
In-Reply-To: 7446fa12-42ce-4716-b0ef-e7eab9005fdb@googlegroups.com

"AdaMagica" <christ-usch.grein@t-online.de> wrote in message 
news:7446fa12-42ce-4716-b0ef-e7eab9005fdb@googlegroups.com...
> Again some misinformation from anon.
>
> On Friday, May 3, 2013 12:48:29 PM UTC+2, anon wrote:
...
>> Another change is the "Copy by Reference" has been replaced by
>> "Copy by Type".  This change alone defeats the purpose of the
>> "limited private" used in Generics compilation units aka external
>> re-usable libraries which forces existing libraries to be
>> re-written. So, many companies that used Generic libraries are
>> now leaving Ada for a language that does not alter a major language
>> feature after 25 plus years of the language existence.
>
> I guess return-by-reference vs. build-in-place is meant here.
> That was a change from Ada 95 to Ada 2005.
> ARG felt that return-by-reference was a big mistake, so they corrected it.
> Ada83 functions returning tasks were a big problem.

Not to mention that it was an Ada 95 invention. There's nothing quite like 
in in Ada 83. So you could equally complain about it's introduction.

It is true, however, that the elimination of return-by-reference (a truely 
useless idea in my experience) has caused some companies to stick with Ada 
95. It took heroic work-arounds to make return-by-reference useful for 
anything, but if you put one of those workarounds into your system, it's 
equally hard to get it out. (Claw in fact has one of those for the 
predefined registry keys, Ada 2005 requires a rather different package 
body -- not a huge deal but a definite annoyance.)

...
>> And both functions with "in out" parameters and "conditional
>> statements" can cause erroneous coding which leads to erroneous
>> executions.

LoL. I'm imagining the group of people protesting against the inclusion of 
"if statements" in Ada 83, because it can cause "erroneous coding". And I'm 
trying to imagine a programming language without "conditional statements" --  
a purely functional language doesn't have "statements", so it might qualify, 
but then of course it would have "conditional expressions" instead.

I suppose "anon" really meant "conditional expressions", but how those can 
"cause erroneous coding" is beyond me. The parts of a conditional expression 
are subject to the same rules as any other Ada expression, including type 
checking, accessibility checking, and all of the legality rules. It's just a 
more convinient way to write an if or case statement (with the added benefit 
of potentially being a static expression).

Indeed, Janus/Ada turns most if and case *statements* into *expressions* for 
optimization purposes. This is a semantics-preserving transformation (in 
both directions), so it's hard to imagine why "if statements" are OK and "if 
expressions" are not.

...
> You may like or dislike these features, but they do not introduce side 
> effects
> into functions, they only make the previous hidden ways obvious.

The problem with "in out" parameters (for *any* subprogram) is at the call 
site, not in the declaration. And that problem stems from the fact that Ada 
does not require an order of evaluation in expressions (including calls). 
That very bad decision will always make Ada less safe (any version of Ada, 
going back to Ada 83) than a language that requires a specific order. It's 
easy to write expressions in Ada 95 that depend on the order of evaluation, 
and you'll never find out until you use a different compiler or optimization 
setting.

Ada 2012 at least tries to mitigate this problem by making obvious cases of 
order dependency illegal. But it cannot fix the root problem -- which in out 
parameters for functions just makes a bit more visible.

(And of course, nothing requires any user of Ada 2012 to use a "in out" 
parameter to a function nor a conditional expression. Put it into your style 
guide to avoid them if you like - and if you don't have an enforced style 
guide, you've got much larger [management] problems than anything a new 
language version could dish out. The ARG does not send people to every Ada 
programmer's place of business demanding that programmers use "in out" 
parameters, conditional expressions, and aspect specifications instead of 
those old obsolete if statements and pragmas! :-)

                                                 Randy.





  reply	other threads:[~2013-05-03 23:54 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)
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 [this message]
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