;;; This is a -*-Lisp-*- file. ;;; ;;; ********************************************************************** ;;; This code was written as part of the Spice Lisp project at ;;; Carnegie-Mellon University, and has been placed in the public domain. ;;; Spice Lisp is currently incomplete and under active development. ;;; If you want to use this code or any part of Spice Lisp, please contact ;;; Scott Fahlman (FAHLMAN@CMUC). ;;; ********************************************************************** ;;; ;;; Keyword parsing macro for Spice Lisp. ;;; Written by Skef Wholey. ;;; Rewritten by Walter van Roggen, 26 December 1982. ;;; ;;; This macro must be part of the compiler. ;;; ;;; ********************************************************************** ;;; ;;; With-Keywords &rest [Macro] ;;; ;;; is a flat list of pairs ( ...) ;;; is a list of one or more lists of ( ). ;;; The is the user-visible keyword, the is the local variable ;;; to be bound to the value supplied for a given keyword, and is ;;; the value to be used if none is found in the . s ;;; evaluated just as they would in the variable binding part of a LET. ;;; is evaluated; is not. ;;; ;;; ********************************************************************** ;;; this is missing a check for unexpected keywords. ;;; (I have the code for it, but haven't installed it -- WvR) (eval-when (compile eval load) (defmacro with-keywords (option-list key-list &rest body) `(let ,(mapcar #'(lambda (kl) `(,(cadr kl) ;var (let ((rest-options (memq ',(car kl) ,option-list))) (if rest-options (cadr rest-options) ;may return NIL ,(caddr kl)))) ) ;default key-list) . ,body )) )