WJ
unread,May 7, 2012, 8:50:06 AM5/7/12You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Antony Sequeira wrote:
> I am reading OnLisp trying to learn macros.
> I am having trouble with the following two
>
> ;;pp. 145
> ;;evaluate a body with bunch of symbols in list syms set to gensyms
> (defmacro with-gensyms (syms &body body)
> `(let ,(mapcar #'(lambda (s)
> `(,s (gensym)))
> syms)
> ,@body))
>
> ;;pp. 169
> ;;sets a bunch of varibales in args to the value val
> (defmacro allf (val &rest args)
> (with-gensyms (gval)
> `(let ((,gval ,val))
> (setf ,@(mapcan #'(lambda (a) (list a gval))
> args)))))
Racket:
(define-syntax-rule (set-all val var ...)
(begin
(set! var val) ...))
> (define x 0)
> (define y 0)
> (set-all 88 x y)
> x
88
> y
88