|By value-result vs by reference email@example.com (1994-04-21)|
|Re: By value-result vs by reference firstname.lastname@example.org (1994-04-21)|
|By value-result vs by reference email@example.com (1994-04-21)|
|Re: By value-result vs by reference firstname.lastname@example.org (1994-04-21)|
|Re: By value-result vs by reference Dik.Winter@cwi.nl (1994-04-21)|
|Re: By value-result vs by reference email@example.com (1994-04-22)|
|Re: By value-result vs by reference firstname.lastname@example.org (1994-04-24)|
|Re: By value-result vs by reference email@example.com (1994-04-23)|
|Re: By value-result vs by reference firstname.lastname@example.org (1994-04-26)|
|Re: By value-result vs by reference Theo.Norvell@comlab.oxford.ac.uk (1994-04-26)|
|Re: By value-result vs. by reference email@example.com (1994-04-28)|
|Re: By value-result vs by reference firstname.lastname@example.org (1994-04-28)|
|Re: By value-result vs by reference email@example.com (1994-04-29)|
|[2 later articles]|
|From:||firstname.lastname@example.org (Andrew Dunstan)|
|Organization:||cleese.apana.org.au Public Access UNIX +61-8-3736006|
|Date:||Sun, 24 Apr 1994 02:20:51 GMT|
email@example.com (Frederic Guerin) writes:
>I would like to hear about call-by-value-result vs call-by-reference,
>which one is better ?
Henry G. Baker (firstname.lastname@example.org) wrote:
: Unfortunately, due to significant differences in efficiency, many
: language designers weasel out at the last minute and allow implementations
: to defy a consistent semantics. The results of this weaselling are fast,
: unportable programs and slow, portable programs.
: The biggest weasel hole around is in Ada, which refuses to take a stand at
: all, and therefore if your program can tell the difference, it is
Scalars in Ada MUST be passed by value/result. No weaselling there!
Structured objects MAY be passed by reference, for fairly obvious
efficiency reasons, but, as you say, a program which can tell the
difference, i.e. which will produce different results depending on whether
or not the compiler passes arrays by reference, is erroneous.
Is this "weaselling"? Why should it be? Plenty of languages have things
which are implementation defined. A classic example is the order of
evaluation of operands. Try something like this with a whole bunch of C
x = y == y++ ;
Sometimes x will be 1, sometimes 0. Were the designers of C weaselling?
Barring the presence of an exception, the only way that you can "tell the
difference" in Ada is to write a routine that has a side effect directly
modifying its parameters, i.e. by aliasing. If you write code like that
you deserve what you get. The language designers should not be required to
cater for idiots writing bad code.
Why use value/result? Well, when a subprogram exits via an exception, the
result is not copied back (at least in Ada), so you haven't corrupted your
actual parameter. This makes for rather cleaner semantics in the presence
[Hey, some of my best friends are weasels. -John]
Return to the
Search the comp.compilers archives again.