comparison lisp/backquote.el @ 5281:aa20a889ff14

Remove a couple of redundant functions, backquote.el 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * backquote.el (bq-vector-contents, bq-list*): Remove; the former is equivalent to (append VECTOR nil), the latter to (list* ...). (bq-process-2): Use (append VECTOR nil) instead of using #'bq-vector-contents to convert to a list. (bq-process-1): Now we use list* instead of bq-list * subr.el (list*): Moved from cl.el, since it is now required to be available the first time a backquoted form is encountered. * cl.el (list*): Move to subr.el.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 10 Oct 2010 12:13:32 +0100
parents 3ecd8885ac67
children b9167d522a9a
comparison
equal deleted inserted replaced
5280:59a6419f7504 5281:aa20a889ff14
182 (t 182 (t
183 (bq-process-1 flag result))))) 183 (bq-process-1 flag result)))))
184 184
185 ;;; ---------------------------------------------------------------- 185 ;;; ----------------------------------------------------------------
186 186
187 (defun bq-vector-contents (vec)
188 (let ((contents nil)
189 (n (length vec)))
190 (while (> n 0)
191 (setq n (1- n))
192 (setq contents (cons (aref vec n) contents)))
193 contents))
194
195 ;;; This does the expansion from table 2. 187 ;;; This does the expansion from table 2.
196 (defun bq-process-2 (code) 188 (defun bq-process-2 (code)
197 (cond ((vectorp code) 189 (cond ((vectorp code)
198 (let* ((dflag-d 190 (let* ((dflag-d (bq-process-2 (append code nil))))
199 (bq-process-2 (bq-vector-contents code))))
200 (cons 'vector (bq-process-1 (car dflag-d) (cdr dflag-d))))) 191 (cons 'vector (bq-process-1 (car dflag-d) (cdr dflag-d)))))
201 ((atom code) 192 ((atom code)
202 (cond ((null code) (cons nil nil)) 193 (cond ((null code) (cons nil nil))
203 ((or (numberp code) (eq code t)) 194 ((or (numberp code) (eq code t))
204 (cons t code)) 195 (cons t code))
276 thing) 267 thing)
277 ((eq flag 'quote) 268 ((eq flag 'quote)
278 (list 'quote thing)) 269 (list 'quote thing))
279 ((eq flag 'vector) 270 ((eq flag 'vector)
280 (list 'apply '(function vector) thing)) 271 (list 'apply '(function vector) thing))
281 (t (cons (cdr 272 (t (cons flag thing))))
282 (assq flag
283 '((cons . cons)
284 (list* . bq-list*)
285 (list . list)
286 (append . append)
287 (nconc . nconc))))
288 thing))))
289
290 ;;; ----------------------------------------------------------------
291
292 (defmacro bq-list* (&rest args)
293 "Return a list of its arguments with last cons a dotted pair."
294 (setq args (reverse args))
295 (let ((result (car args)))
296 (setq args (cdr args))
297 (while args
298 (setq result (list 'cons (car args) result))
299 (setq args (cdr args)))
300 result))
301 273
302 (provide 'backquote) 274 (provide 'backquote)
303 275
304 ;;; backquote.el ends here 276 ;;; backquote.el ends here