From e93416cc05a38b34956e88b9516af5b910d5df19 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sun, 3 Feb 2008 09:46:55 +0100 Subject: Add a compiler macro for SELECTOR. darcs-hash:4e7f3cf6846d15869487905f52589ee8250bcf5d --- Lisp/compiler-macros.lisp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Lisp/compiler-macros.lisp') diff --git a/Lisp/compiler-macros.lisp b/Lisp/compiler-macros.lisp index 72471d5..79fd0a6 100644 --- a/Lisp/compiler-macros.lisp +++ b/Lisp/compiler-macros.lisp @@ -66,6 +66,26 @@ form)) +;; Optimise all (SELECTOR ...) forms. This is important in order to +;; make (FUNCALL (SELECTOR ...) ...) efficient. +(define-compiler-macro selector (&whole form method-name) + (if (and (constantp method-name) + (not (and (listp method-name) + (eq 'load-time-value (car method-name))))) + `(load-time-value (handler-case + (find-selector ,method-name) + (serious-condition () + (warn + (make-condition 'simple-style-warning + :format-control + "~S designates an unknown ~ + method selector." + :format-arguments + (list ,method-name))) + ,method-name))) + form)) + + ;; This compiler macro is a bit more complicated than the preceding ;; ones. (define-compiler-macro invoke (receiver message-start &rest message-components) -- cgit v1.2.3