[racket] Pass by value/name/reference
Oops, I have to reply to myself. Matthew correctly reminded me that it is
call-by-value/pass-by-worth
what I mean for Racket and Java not .../pass-by-reference. Sorry for the
confusion.
On Jul 20, 2014, at 6:27 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> call-by is a notion of time, pass-by refers to entity that is used (location if you so will). You can create a 2-dimension table of these options and you'll be able to find some language for almost any cell in this table.
>
> The common meaning of call-by-value is call-by-value/pass-by-reference. Both Java and Racket and a whole lot of languages use this combination. Call-by-name is also a common reference to call-by-name/pass-by-reference, see Algol 60 for an example.
>
> You can also create a calculus for any cell in this table. Google for Crank and Felleisen and POPL and you'll find something. With that I mean
>
> (1) a calculus whose basic axiom(s) capture/s the mechanics of parameter passing
> (2) and that satisfies Church-Rosser and has a Standardization Theorem (which defines a deterministic strategy for evaluation terms)
> (3) and whose ST coincides with the conventional evaluator/abstract machine
>
> This holds for call-by-name, call-by-value (common meanings), in purely functional or imperative settings, and it extends to call-by-copy and several other mechanisms.
>
> The phrase "call-by-value is a reduction strategy" has no meaning per se but is a left over from the time when people hadn't figured out the above (pre 1070).
>
> It sounds like you're taking a course on PL and got some exercises to solve. I am glad we can help, and I assume you will give credit to the mailing list.
>
>
>
> On Jul 20, 2014, at 2:44 PM, Jon Zeppieri wrote:
>
>> 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
>>
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users
>