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

Re : set in Scheme



Sorry about the last message, I wrote the set macro down a little too
fast and it clearly won't work as intended.  I meant to say something
like this:

(macro set
   (lambda (e)
      (list 'eval
            (list 'list
                  ''set!
                  (list 'eval (list 'quote (cadr e)))
                  (list 'quote (caddr e))))))

Then if you

(define a 's)
(define s 'any)
(define b 'r)

the effect of (set a b) should be to assign the value r to s. 

So far so good.  But what about this function?

(define foo
   (lambda (x y)
      (set x y)))

If we (define s 'any) then the effect of (foo a b) is the same as above.

Judging by my last posting, this may not be perfect either, but at least it's 
a lot closer.  I'd be interested in seeing a shorter or better solution.  

Thanks for your patience.

-- Brad Pierce

<pierce@cs.ucla.edu>