comparison lisp/cl-macs.el @ 5338:8608eadee6ba

Move #'delq, #'delete to Lisp, adding support for sequences. src/ChangeLog addition: 2011-01-11 Aidan Kehoe <kehoea@parhasard.net> * device-msw.c (Fmswindows_printer_list): Remove a Fdelete () call here, remove the necessity for it. * fns.c (Fdelete, Fdelq): * lisp.h: Move #'delete, #'delq to Lisp, implemented in terms of #'delete* * select.c (Fown_selection_internal): * select.c (handle_selection_clear): Use delq_no_quit() in these functions, don't reimplement it or use Fdelq(), which is now gone. lisp/ChangeLog addition: 2011-01-11 Aidan Kehoe <kehoea@parhasard.net> * subr.el (delete, delq, remove, remq): Move #'remove, #'remq here, they don't belong in cl-seq.el; move #'delete, #'delq here from fns.c, implement them in terms of #'delete*, allowing support for sequences generally. * update-elc.el (do-autoload-commands): Use #'delete*, not #'delq here, now the latter's no longer dumped. * cl-macs.el (delete, delq): Add compiler macros transforming #'delete and #'delq to #'delete* calls.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 14 Jan 2011 23:35:29 +0000
parents 7b391d07b334
children ba62563ec7c7
comparison
equal deleted inserted replaced
5337:906ccc7dcd70 5338:8608eadee6ba
3340 (if (and (cl-simple-expr-p a) (cl-simple-expr-p list) 3340 (if (and (cl-simple-expr-p a) (cl-simple-expr-p list)
3341 (not (memq :key keys))) 3341 (not (memq :key keys)))
3342 (list 'if (list* 'member* a list keys) list (list 'cons a list)) 3342 (list 'if (list* 'member* a list keys) list (list 'cons a list))
3343 form)) 3343 form))
3344 3344
3345 (define-compiler-macro remove (item sequence) 3345 (define-compiler-macro delete (&whole form &rest args)
3346 `(remove* ,item ,sequence :test #'equal)) 3346 (symbol-macrolet
3347 3347 ((not-constant '#:not-constant))
3348 (define-compiler-macro remq (item sequence) 3348 (let ((cl-const-expr-val (cl-const-expr-val (nth 1 form) not-constant)))
3349 `(remove* ,item ,sequence :test #'eq)) 3349 (if (and (cdr form) (not (eq not-constant cl-const-expr-val))
3350 3350 (or (symbolp cl-const-expr-val) (fixnump cl-const-expr-val)
3351 (characterp cl-const-expr-val)))
3352 (cons 'delete* (cdr form))
3353 `(delete* ,@(cdr form) :test #'equal)))))
3354
3355 (define-compiler-macro delq (&whole form &rest args)
3356 (symbol-macrolet
3357 ((not-constant '#:not-constant))
3358 (let ((cl-const-expr-val (cl-const-expr-val (nth 1 form) not-constant)))
3359 (if (and (cdr form) (not (eq not-constant cl-const-expr-val))
3360 (not (cl-non-fixnum-number-p cl-const-expr-val)))
3361 (cons 'delete* (cdr form))
3362 `(delete* ,@(cdr form) :test #'eq)))))
3363
3364 (define-compiler-macro remove (&whole form &rest args)
3365 (symbol-macrolet
3366 ((not-constant '#:not-constant))
3367 (let ((cl-const-expr-val (cl-const-expr-val (nth 1 form) not-constant)))
3368 (if (and (cdr form) (not (eq not-constant cl-const-expr-val))
3369 (or (symbolp cl-const-expr-val) (fixnump cl-const-expr-val)
3370 (characterp cl-const-expr-val)))
3371 (cons 'remove* (cdr form))
3372 `(remove* ,@(cdr form) :test #'equal)))))
3373
3374 (define-compiler-macro remq (&whole form &rest args)
3375 (symbol-macrolet
3376 ((not-constant '#:not-constant))
3377 (let ((cl-const-expr-val (cl-const-expr-val (nth 1 form) not-constant)))
3378 (if (and (cdr form) (not (eq not-constant cl-const-expr-val))
3379 (not (cl-non-fixnum-number-p cl-const-expr-val)))
3380 (cons 'remove* (cdr form))
3381 `(remove* ,@(cdr form) :test #'eq)))))
3382
3351 (macrolet 3383 (macrolet
3352 ((define-foo-if-compiler-macros (&rest alist) 3384 ((define-foo-if-compiler-macros (&rest alist)
3353 "Avoid the funcall, variable binding and keyword parsing overhead 3385 "Avoid the funcall, variable binding and keyword parsing overhead
3354 for the FOO-IF and FOO-IF-NOT functions, transforming to forms using the 3386 for the FOO-IF and FOO-IF-NOT functions, transforming to forms using the
3355 non-standard :if and :if-not keywords at compile time." 3387 non-standard :if and :if-not keywords at compile time."