5
(defmacro once-only (((v val) . res) &body body)
6
(cond (res `(once-only ((,v,val)) (once-only ,res ,@ body)))
7
((and (consp val) (or (eq (car val) 'function)(eq (car val) 'quote)))
8
`(symbol-macrolet ((,v ,val)) ,@ body))
11
(symbol-macrolet ((,v ,w))
14
(defun get-test (x &aux item lis res key fn)
16
(desetq (item lis . res) (cdr x))
18
(desetq (key fn . res) res)
22
(member (car fn) '(quote function)))))
27
(setf (get 'assoc 'bo1) 'bo1-assoc)
28
(defun bo1-assoc (x where &aux fn ) where
29
(when (setq fn (get-test x))
30
`(funcall #'(lambda (item lis)
32
when (funcall #',fn (car v) item)
36
(setf (get 'member 'bo1) 'bo1-member)
37
(defun bo1-member (x where &aux fn ) where
38
(when (setq fn (get-test x))
39
`(funcall #'(lambda (item lis)
41
when (funcall #',fn (car v) item)
45
(setf (get 'get 'bo1) 'bo1-get)
46
(defun bo1-get (x where) where
47
(when (and (= *safety* 0) (< *space* 2))
48
`(funcall #'(lambda (plis key &optional dflt)
49
(setq plis (symbol-plist plis))
50
(loop (cond ((null plis) (return dflt))
51
((eq (car plis) key)(return (cadr plis)))
52
(t (setq plis (cddr plis))))))
55
(setf (get 'mapcar 'bo1) 'bo1-mapcar)
56
(setf (get 'mapc 'bo1) 'bo1-mapcar)
57
(setf (get 'mapcan 'bo1) 'bo1-mapcar)
58
(defun bo1-mapcar (x where &aux fn l coll) where
59
(when (and (= *safety* 0) (< *space* 2))
60
(desetq (fn l) (cdr x))
61
(setq coll (cdr (assoc (car x) '((mapcar . collect) (mapc . do)
64
((and (consp fn) (member (car fn) '(quote function)))
65
`(funcall #'(lambda (lis)
66
(sloop for v in lis ,coll (funcall ,fn v)))
68
(t `(funcall #'(lambda (fn lis)
69
(if (symbolp fn) (setq fn (symbol-function fn)))
70
(sloop for v in lis ,coll (funcall fn v)))
73
(setf (get 'funcall 'bo1) 'bo1-funcall)
74
(defun bo1-funcall (x where &aux fn tem args ll w binds) where
75
(desetq (fn . args) (cdr x))
76
(cond ((and (consp fn)
77
(or (eq (car fn) 'quote)
78
(eq (car fn) 'function))
82
`(,(cadr fn) ,@ args))
84
(cond ((and (consp tem) (eq (car tem) 'lambda))
85
(desetq (ll) (cdr tem))
86
(setq ll (decode-ll ll))
87
(cond ((and (null (ll &key ll))
90
(sloop for v in (ll &required ll)
92
(setq args (cdr args))
93
(push (list v w) binds))
94
(sloop for v in (ll &optional ll)
97
(or (consp args) (comp-error "bad arglist in ~a " x))
98
(push (list (car v) (pop args)) binds))
99
(t (push (list (car v) (cadr v)) binds)))
101
(push (list (caddr v)
104
`(let ,(nreverse binds)
108
(setf (get 'typep 'b1.5) 'b1.5-typep)
109
(defun b1.5-typep (x where &aux (cd (third x))
110
(args (call-data-arglist cd)))
112
(let ((rt (result-type (nth 0 args)))
114
(cond ((and (consp typ)
116
(subtypep rt (THIRD typ)))
119
(defmacro dotimes ((var form &optional (val nil)) &rest body
120
&aux (temp (gensym)))
121
`(do* ((,temp ,form) (,var 0 (1+ ,var)))
122
((>= ,var ,temp) ,val)
123
,@ (cond ((typep form 'fixnum)
124
`((declare (fixnum ,temp ,var)))))
127
(defmacro psetq (&optional var val &rest l &aux sets types decls binds)
128
(cond ((null var) nil)
129
((null l) `(setq ,var ,val))
131
(push `(,(gensym) ,val) binds)
133
(push (caar binds) sets)
134
(push `(type (type-of ,var) ,(caar binds)) types)
136
(desetq (var val) l) (setq l (cddr l)))
137
`(let ,(nreverse binds)
139
(setq ,@(nreverse sets))))))
144
;;- version-control:t