This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Change to variable interface request


Maciej Stachowiak wrote:

> 
> Well, viewed that way, I don't think Jim likes the idea of variables
> with magic side effects, and I'd have to add that allowing only one
> kind of magic side effect (mutating a cons cell) is worse, if
> anything, than not allowing them at all.
> 

How about a compromise?  Instead of variable-bind-pair how
about something like :

> (define x '(x . 3))
> (define (xvar-lookup set? . newval)
...  (if set?
...      (set-cdr! x (car newval))
...      (cdr newval)))
>(define xvar (variable-bind-proc xvar-lookup 'x))
>(variable-set! xvar 10)
>x
(x. 10)
> (variable-ref xvar)
10

This would mirror the lookup closures used by eval2.  But using it
in evals would generate a lot of garbage.

Wade