comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Ada to 'C' parameter passing problem
Date: Fri, 21 Feb 2003 13:12:33 -0500
Date: 2003-02-21T13:12:33-05:00	[thread overview]
Message-ID: <3E566C11.1020904@cogeco.ca> (raw)
In-Reply-To: 3E55F70B.A254EAF@0.0

Stuart Palin wrote:
> Simon Wright wrote:
>>I recall Robert Dewar saying that he thought that restricting
>>functions to "in" (or access) parameters was a Bad Idea -- Ada is a
>>programming language, not a mathematical abstraction, and there is
>>nothing in Ada to stop a function modifying global state. (Praise be,
>>say I). But Robert got outvoted during the Ada 9X process.
> 
> I would think that there are [at least] a couple of
> conflicting inputs to this.
> 
> 1) By allowing functions to have side-effects you create
> problems related to expression evaluation order - which
> introduces an additional source of compiler dependencies.
> 
> 2) Modifying global state is not prevented by the language
> rules.  
...
> Would allowing function parameters to be in out/out be
> encouraging a risky practice, or a recognition that the
> language can not fully police the concept.
> 
> I favour the existing language rules which at least do not
> 'encourage' the risks that might arise through functions
> with side-effects.
> 
> [RD does not usually make unconsidered statements, so I
> would be interested in reading his line of arguments.  Is it
> available somewhere convenient?]
> --
> Stuart Palin

I can see that there is value in being able to say, while
reading somebody's code: "this is a function, hence there is
no state change here."

But, we all know that this isn't enforced in the language,
beyond the trivial aspect of restricting parameter use (even
that is inconsistent, because access parameters are permitted).

The function being called can be changing state within the
package it is defined in, or even calling other functions
and procedures that change states in other places to boot.
So this idea cannot be trusted to begin with.

So with my own personal "practical hat" on, I'd have to
side with those in favour of opening up the function
arguments to permit in/out, out parameters. The present
arrangement only _discourages_ side effects, and perhaps
this is something that some feel is worth maintaining.

If it becomes a requirement to provide purely functional
calls (ie. with no side effect), then I think it is
mandatory for some other mechanism to exist and
have it enforced by the compiler, IMHO.
-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




  parent reply	other threads:[~2003-02-21 18:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-18 15:39 Ada to 'C' parameter passing problem Patrick
2003-02-18 16:47 ` Jeffrey Carter
2003-02-18 19:50 ` Rod Chapman
2003-02-20  2:36   ` Matthew Heaney
2003-02-20  9:18     ` Rod Chapman
2003-02-20  9:43       ` Dmitry A. Kazakov
2003-02-20 22:05       ` Simon Wright
2003-02-21  9:53         ` Stuart Palin
2003-02-21 17:39           ` Jeffrey Carter
2003-02-21 18:12           ` Warren W. Gay VE3WWG [this message]
2003-02-21 20:25           ` Randy Brukardt
2003-02-24 23:53       ` Matthew Heaney
2003-02-25 17:21         ` Rod Chapman
  -- strict thread matches above, loose matches on Subject: below --
2003-02-21 16:52 Lionel.DRAGHI
replies disabled

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