Path: utzoo!attcan!uunet!mcsun!ukc!mucs!m1!bevan From: bevan@cs.man.ac.uk (Stephen J Bevan) Newsgroups: comp.lang.lisp Subject: Help with Macros [longish] Message-ID: Date: 21 Sep 90 14:46:33 GMT Sender: news@cs.man.ac.uk Organization: Department of Computer Science, University of Manchester Lines: 40 I've recently been reading a book on Scheme (The Scheme Programming Language - R. Kent Dybvig) and in it, it uses a function `record-case'. This is similar to `case' except that it does destructuring. So for example I could define the following function which given some expressions as lists, evaluates them. (defun eval-expr (x) (record-case x (add (x y) (+ x y)) (sub (x y) (- x y)) (mul (x y) (* x y)) (div (x y) (/ x y)) ) ) >(foo '(add 3 4)) 7 >(foo '(mul 4 5)) 20 This notation is particularly nice if you are writing simple evaluators for languages. Here's the problem. I've tried to implement this in Lisp myself, but to no avail. I've RTFM on macros* but I can't seem to get the arguments to evaluate at the correct time. So I'm hoping some kind soul will show me how this is done. If you are a real masochist I can even send you the code I've written so far (all 53 lines of it!), so you can point out what is wrong with it. Yours a struggling Lisper, Stephen J. Bevan bevan@cs.man.ac.uk * if fact I've got all of the following in front of me Common Lisp, Steele et al. Common Lisp - A Tutorial, Wendy L. Milner Lisp, Winston & Horn but I'm still can't get the parms. to evaluate when I want them to.