Re: XS: possible to have side effects?

Subject: Re: XS: possible to have side effects?
From: James Clark <jjc@xxxxxxxxxx>
Date: Sun, 08 Jun 1997 13:34:36 +0700
At 04:56 08/06/97 +0700, I wrote:

>My proposal involves adding a primitive operation to the language which is
>to make an object and all objects reachable from that object read-only.  Now
>when that operation is applied to a closure it must make read-only the
>values saved for all the free variables in the closure (needed because of
>something like
>
>(define x
>  (let ((v (vector 1))
>    (lambda ()
>      v))
>
>).

I should clarify one thing here.  When a variable that is free in a lambda
expression is assigned to within the lambda expression with set!, then what
is conceptually saved with the closure is not the value of the variable but
its location.  For example, given

  (define x (let ((n 0)) (lambda () (set! n (+ 1 n)) n)))

repeated calls to (x) will return 1, 2, 3,...

In this case making the procedure read-only means starting with the location
and making everything reachable from it read-only, rather than starting with
the value.

James



 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread