1 ;;; liece-clfns.el --- compiler macros for emulating cl functions
2 ;; Copyright (C) 1998-2000 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: cl, compile
8 ;; This file is part of Liece.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
28 ;; This file is borrowed from `gnus-clfns.el' from T-gnus.
29 ;; Avoid cl runtime functions for FSF Emacsen.
33 (if (featurep 'xemacs)
37 (define-compiler-macro last (&whole form x &optional n)
38 (if (and (fboundp 'last)
39 (subrp (symbol-function 'last)))
42 `(let* ((x ,x) (n ,n) (m 0) (p x))
52 (while (consp (cdr x))
56 (define-compiler-macro member-if (&whole form pred list)
57 (if (and (fboundp 'member-if)
58 (subrp (symbol-function 'member-if)))
62 (while (and seq (not (funcall fn (car seq))))
66 (define-compiler-macro member-if-not (&whole form pred list)
67 (if (and (fboundp 'member-if-not)
68 (subrp (symbol-function 'member-if-not)))
72 (while (and seq (funcall fn (car seq)))
76 (define-compiler-macro delete-if (&whole form pred list)
77 (if (and (fboundp 'delete-if)
78 (subrp (symbol-function 'delete-if)))
80 `(let* ((fn ,pred) (seq ,list) (p seq))
81 (while (and p (not (funcall fn (car p))))
83 (if p (delq (car p) seq)))))
85 (define-compiler-macro remove-if (&whole form pred list)
86 (if (and (fboundp 'remove-if)
87 (subrp (symbol-function 'remove-if)))
89 `(let* ((fn ,pred) (seq (copy-sequence ,list)) (p seq))
90 (while (and p (not (funcall fn (car p))))
92 (if p (delq (car p) seq) seq))))
94 (define-compiler-macro remove-if-not (&whole form pred list)
95 (if (and (fboundp 'remove-if-not)
96 (subrp (symbol-function 'remove-if-not)))
98 `(let* ((fn ,pred) (seq (copy-sequence ,list)) (p seq))
99 (while (and p (funcall fn (car p)))
101 (if p (delq (car p) seq) seq))))
103 (define-compiler-macro assoc-if (&whole form pred list)
104 (if (and (fboundp 'assoc-if)
105 (subrp (symbol-function 'assoc-if)))
107 `(let ((fn ,pred) (seq ,list))
108 (while (and seq (not (funcall fn (caar seq))))
112 (define-compiler-macro rassoc-if (&whole form pred list)
113 (if (and (fboundp 'rassoc-if)
114 (subrp (symbol-function 'rassoc-if)))
116 `(let ((fn ,pred) (seq ,list))
117 (while (and seq (not (funcall fn (cdar seq))))
121 (provide 'liece-clfns)
123 ;;; liece-clfns.el ends here