[racket] Pass by value/name/reference

From: Jon Zeppieri (zeppieri at gmail.com)
Date: Sun Jul 20 14:44:01 EDT 2014

On Sun, Jul 20, 2014 at 5:02 AM, קוראל אלימלך <coral2301 at gmail.com> wrote:
> Hey :)
> How the arguments are passed in racket?
> by value/ reference/name?
>
> If u can add an example it will b good :)
> Thank U !
>

I suspect two different things are being conflated here:

1. the reduction semantics of the language
2. the question of whether or not data is copied at procedure-call boundaries.


For (1), Racket's reduction strategy is call-by-value. As Jos Koot has
demonstrated, in a procedure-call expression:

  (fn-expr argn-expr...)

all of the sub-expressions will be reduced (that is, evaluated) to
values before the function is applied.

For (2), Racket does not copy data at procedure-call boundaries. If
you pass a mutable struct, the callee is able to make changes to it
that are visible to the caller. This is unlike in C, where you would
need to pass a pointer to a struct in order to allow the callee to
operate on the same instance as the caller.

Unfortunately, "call-by-X" terminology is used to refer to both things
and usually in ways that make matters far more confusing than they
need be. See, e.g.,
[http://en.wikipedia.org/wiki/Evaluation_strategy], which is just
awful.

-Jon


Posted on the users mailing list.