Re: How to update an agrument passed by name in scheme
- From: Matthias Blume <find@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 02 Feb 2006 11:47:45 -0600
Anton van Straaten <anton@xxxxxxxxxxxxxxxx> writes:
H. wrote:
I have to admit I don't get this part of Scheme, in that a lot of
people say "say how much easier it is to do this thing in Scheme as
opposed to whatever other language". But passing by reference is
exceptionally easy in some of those other languages, and not so easy in
Scheme, which, based on this thread, cannot be done trivially.
Simplifying a bit, non-atomic values (pairs, vectors etc.) *are*
passed by reference in Scheme. The OP talked about "passed by name",
which is a little different.
I know you are hiding this under the blanket of "simplifying a bit",
but I would prefer not to confuse issues in this manner. In Scheme
(and in C), *all* values are passed by value, no matter whether they
are "atomic" or "non-atomic". The difference is in the fact that some
values /are/ references, so when they get passed by value, what gets
passed is a reference, namely the reference that is the value.
This is different from what happens with Pascal's VAR parameters or
C++'s reference parameters, where the compiler effectively inserts an
implicit address-of operator at the call site and an implicit
dereference operation at each use of the formal parameter within the
procedure body. In languages that have first-class references (like
C's pointers, Scheme's CONS cells, or ML's ref), one can achieve the
same effect by passing such a first-class reference value. But this
requires to /explicitly/ create the appropriate reference value at the
call site (or earlier), and to /explicitly/ dereference it (*,
car/cdr, !) at each use.
Matthias
.
- Follow-Ups:
- Re: How to update an agrument passed by name in scheme
- From: Anton van Straaten
- Re: How to update an agrument passed by name in scheme
- References:
- How to update an agrument passed by name in scheme
- From: artejera
- Re: How to update an agrument passed by name in scheme
- From: Anton van Straaten
- Re: How to update an agrument passed by name in scheme
- From: Joe Marshall
- Re: How to update an agrument passed by name in scheme
- From: H.
- Re: How to update an agrument passed by name in scheme
- From: Anton van Straaten
- How to update an agrument passed by name in scheme
- Prev by Date: Re: How to update an agrument passed by name in scheme
- Next by Date: Re: Stair-Stepping in style
- Previous by thread: Re: How to update an agrument passed by name in scheme
- Next by thread: Re: How to update an agrument passed by name in scheme
- Index(es):
Relevant Pages
|