1

I have to remake backquote (with unquote and unquote-splicing) without using the builtins reader macros `,@ The behaviour expected is:

> (BACKQUOTE (A B (LIST ‘C ‘D) (COMA (LIST ‘E ‘F)
                               (COMA-AT (LIST ‘G ‘H)))
(A B (LIST ‘C ‘D) (E F) G H)

I try to do it with a macro but the results are no the expected.

Many thanks!!!

Any hints of what could be done?

jneira
  • 944
  • 10
  • 18

2 Answers2

3

http://lib.store.yahoo.net/lib/paulgraham/glsbq.lisp has an example

Xach
  • 11,774
  • 37
  • 38
  • mmm i only ask cause the example is a full impl of backquote with more features than my "basic" homework needs but thanks anyway, i'll try to undestand it – jneira Jan 02 '11 at 12:38
0

For Those Who well settle for a simple and incorrect solution but it works, while trying to understand the paul graham code:

(defmacro backquote (expr)
  (labels
      ((step (p n)
             (append p
                     (if (atom n) (list n)
                       (case (car n)
                         ('comma (list (eval (cadr n))))
                         ('comma-at (eval (cadr n))))))))
    (list 'quote (reduce #'step (cons () expr)))))

corrections and suggestions to improve it are welcome!

jneira
  • 944
  • 10
  • 18