guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

set-pair!


From: Maciek Godek
Subject: set-pair!
Date: Wed, 20 Aug 2008 09:27:48 +0200

Hi,
I've been trying to write a function or macro that
would work like this:

(let ((a 0)(b 0))
  (set-pair! '(a . b) '(1 . 2))
  (cons a b)) ; => (1 . 2)

I eventually wrote:

(define (set-pair! pair values)
  (let ( (e (the-environment)) (a (car pair)) (d (cdr pair)) )
     (local-eval
        `(begin
             (set! ,a ,(car values))
             (set! ,d ,(cdr values)))
         e)))

but it seems to work only for symbols defined in
global scope. Does anyone know how to implement
this form properly?

Thanks in advance
Maciek

PS I love you all :)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]