1 ;;; Backquote Implementation from Common Lisp
2 ;;; Author: Guy L. Steele Jr. Date: 27 December 1985
3 ;;; This software is in the public domain
7 ;;; Converted to XLISP from the CLtL book, July, 1991, by Tom Almy
8 ;;; Expression simplification code removed.
10 ;;; Reader Macros -- already exist for ` , and ,@ that generate correct
11 ;;; code for this backquote implementation.
13 ;;; This implementation will execute far slower than the XLISP original,
14 ;;; but since macros expansions can replace the original code
15 ;;; (at least with my modified XLISP implementation)
16 ;;; most applications will run at their full speed after the macros have
17 ;;; been expanded once.
22 (defmacro backquote
(x)
26 (cond ((atom x
) (list 'quote x
))
27 ((eq (car x
) 'backquote
)
28 (bq-process (bq-process (cadr x
))))
29 ((eq (car x
) 'comma
) (cadr x
))
30 ((eq (car x
) 'comma-at
)
31 (error ",@ after ` in ~s" (cadr x
)))
33 (q '() (cons (bq-bracket (car p
)) q
)))
35 (if (null p
) ;; simplify if proper list TAA MOD
36 (cons 'append
(nreverse q
))
38 (nconc (nreverse q
) (list (list 'quote p
))))))
39 (when (eq (car p
) 'comma
)
40 (unless (null (cddr p
)) (error "Malformed: ~s" p
))
44 (when (eq (car p
) 'comma-at
)
45 (error "Dotted ,@ in ~s" p
))
50 (list 'list
(list 'quote x
)))
52 (list 'list
(cadr x
)))
53 ((eq (car x
) 'comma-at
)
55 (t (list 'list
(bq-process x
)))))
57 (setq *features
* (cons :backquote
*features
*))