Call by reference vs. call by value 
Author Message
 Call by reference vs. call by value

Quote:

>This is another Ada feature well covered by the SPARK subset.  The rules
>of SPARK (which are checked by the SPARK Examiner) prohibit all cases
>of aliasing where program meaning might be affected by the parameter
>passing mechanism used. A SPARK program has copy-in, copy-out semantics
>regardless of the compiler used to compile it.

    While I understand the interest in making language mechanisms
    secure and predictable, I sometimes wonder about things like this
    reference/value debate. It seems like a solution desparately
    seeking a problem.

    My experience with software bugs (especially in Ada) is that the
    overwhelming bulk of them are some version of the computer doing
    what you told it to do, not what you meant for it to do. (The
    implementer got the logic wrong) Most forms of semanitc induced
    errors are the kinds of things caught by the compiler (assigning
    reals to integers without explicit conversion, uninitialized
    variables, etc.) Those few weird "corner-case" bugs that fall into
    the category of "the LRM said it was 'implementation dependent'
    and my implementation bit me on the butt" happen so infrequently
    (although are annoyingly difficult to find!) as to not be worth
    the speed penalties imposed by "absolutely provable secure"
    implementations.

    I'd favor passing parameters by reference (for speed) over copy
    mechanisms because in the practical world of "the way programmers
    *really* program", my experience is thus: 1) You almost never see
    code (in the real world) where parameter passing mechanisms cause
    the problems (id est, where compiler "A" would have got it right
    and compiler "B" got it wrong) 2) Most (Ada) compilers are pretty
    good at finding the bulk of the parameter-passing problems no
    matter what the implementation mechanism is through forms of
    static analysis. (They're also pretty smart about figuring out
    what's the *optimal* way to pass the parameters, depending on data
    types.)

    I think we've learned by now that it doesn't help a language to be
    syntactically/semantically "perfect" (curing all the "Language
    Lawyer" problems) at the expense of being slow, cumbersome and
    late to market.

    MDC

Marin David Condic, Senior Computer Engineer    ATT:        407.796.8997
M/S 731-96                                      Technet:    796.8997
Pratt & Whitney, GESP                           Fax:        407.796.4669


===============================================================================
    "Government is not reason. It is not eloquence. It is a force.
    Like fire, a dangerous servant and a fearful master."

        --  George Washington
===============================================================================



Mon, 11 Jan 1999 03:00:00 GMT  
 Call by reference vs. call by value

Quote:


> >This is another Ada feature well covered by the SPARK subset.  The rules
> >of SPARK (which are checked by the SPARK Examiner) prohibit all cases
> >of aliasing where program meaning might be affected by the parameter
> >passing mechanism used. A SPARK program has copy-in, copy-out semantics
> >regardless of the compiler used to compile it.

[snip]
>     I'd favor passing parameters by reference (for speed) over copy
>     mechanisms ...

SPARK does not enforce copying it simply ensures that the program _behaves_
as if parameters were copied even if the compiler passes by reference.  

I agree with many of your comments, but for the most critical of systems
not worrying about the obscure/rare error cases is not an option. Also,
tightening the language to the point where we can reason properly about
program meaning allows us to tackle the serious problem you identify of
the getting the logic wrong.  The kinds of formal verification we
routinely practice on critical code are simply not feasible if the meaning
of a source text in not fully defined.

Peter



Tue, 12 Jan 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Call by reference vs. call by value

2. Call-by-value vs. call-by-need/name

3. is javascript call-by-reference or value?

4. call by value/reference conundrum (C<->Fortran)

5. Call by Reference / Value

6. IV Called by reference doesn't open when called

7. Cross reference/Call structure tools for C function calls

8. call-with-values & call/cc

9. multiple values vs proc calls

10. call sync_memory vs call sync_memory()

11. Call by Reference/Content vs. Using by Reference/Value

12. Scheme values and call-with-values

 

 
Powered by phpBB® Forum Software