Re: How to update an agrument passed by name in scheme
- From: Pascal Bourguignon <usenet@xxxxxxxxxxxxxxxxx>
- Date: Thu, 02 Feb 2006 18:32:00 +0100
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.
Well, since AFAIK, scheme cannot "pass by name", we interpreted it as
"pass by reference".
In Common Lisp, we could "pass by name" global variables:
(defun do-something (name) (incf (symbol-value name)))
(defvar *x* 0)
(defvar *y* 0)
(do-something '*x*)
(do-something '*y*)
(do-something '*y*)
(list *x* *y*)
--> (1 2)
This wouldn't work for lexical variables.
IIRC, Algol had "pass by name" too, and this kind of argument passing
is a big software engineering failure.
As for lisp argument passing, indeed compound values are passed by
references and simple values are passed by value (Independently of boxing).
Becareful: vectors, strings, bignums, fixnums, characters, etc, all
but pairs ARE atomic! atom <=> not pair
--
__Pascal Bourguignon__ http://www.informatimago.com/
"What is this talk of "release"? Klingons do not make software
"releases". Our software "escapes" leaving a bloody trail of
designers and quality assurance people in its wake."
.
- 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: Metaprogramming using Scheme
- Next by Date: Re: How to update an agrument passed by name in scheme
- 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
|