;; file of common cmu functions which should be macros ;; I hope that by just loading in the file an environment will be ;; created which will permit the cmu files to be compiled. (setq rcs-cmumacs- "$Header: /usr/lib/lisp/cmumacs.l,v 1.1 83/01/29 18:34:31 jkf Exp $") (declare (macros t)) (eval-when (compile eval load) (or (boundp 'CMU-fcn-def) (setq CMU-fcn-def (getd 'def)))) ;-- contents ; dv mark!changed *** list* [construct-list* lambda] ; neq push pop mukname (equivlance) ; prin1 (equiv to print) selectq lineread ; ;--- dv :: set variable to value and remember it was changed ; (dv name value) name is setq'ed to value (no evaluation) and ; the fact that it was done is remembered ; (defmacro dv (name value) `(progn 'compile (setq ,name ',value) (mark!changed ',name))) (defmacro mark!changed (name) `(let ((atomname ,name)) (and (boundp '%changes) (setq %changes (cons atomname %changes))) atomname)) ;--- *** :: comment macro ; (defmacro *** (&rest x) nil) ;; this must be rewritten as a macro **** ;(def quote! (nlambda (a) (quote!-expr a))) ; this will be thrown away if the code below it works (def quote!-expr (lambda (x) (cond ((atom x) x) ((eq (car x) '!) (cons (eval (cadr x)) (quote!-expr (cddr x)))) ((eq (car x) '!!) (cond ((cddr x) (append (eval (cadr x)) (quote!-expr (cddr x)))) (t (eval (cadr x))))) (t (prog (u v) (setq u (quote!-expr (car x))) (setq v (quote!-expr (cdr x))) (cond ((and (eq u (car x)) (eq v (cdr x))) (return x))) (return (cons u v))))))) ;; this is probably what the above forms do. (jkf) (defmacro quote! (&rest a) (quote!-expr-mac a)) (eval-when (compile eval load) (defun quote!-expr-mac (form) (cond ((null form) nil) ((atom form) `',form) ((eq (car form) '!) `(cons ,(cadr form) ,(quote!-expr-mac (cddr form)))) ((eq (car form) '!!) (cond ((cddr form) `(append ,(cadr form) ,(quote!-expr-mac (cddr form)))) (t (cadr form)))) (t `(cons ,(quote!-expr-mac (car form)) ,(quote!-expr-mac (cdr form)))))) ); end eval-when ;--- the following are macroizations from cmu3.l ;(jkf)- ucb list* macro. ; (defmacro list* (&rest forms) (cond ((null forms) nil) ((null (cdr forms)) (car forms)) (t (construct-list* forms)))) (defun construct-list* (forms) (setq forms (reverse forms)) (do ((forms (cddr forms) (cdr forms)) (return-form `(cons ,(cadr forms) ,(car forms)) `(cons ,(car forms) ,return-form))) ((null forms) return-form))) (defmacro neq (a b) `(not (eq ,a ,b))) (defmacro push (value stack) `(setq ,stack (cons ,value ,stack))) ;(jkf) this is actually maknum is the maclisp terminology (putd 'munknam (getd 'maknum)) ; added for CMULisp compatibilty (used by editor etc) (putd 'prin1 (getd 'print)) ;--- selectq :: case statement type construct ; ; (selectq