whitespace
[sbcl.git] / tests / macro-policy-test.lisp
blob3dccbc553c4926611c8f80912e64550c6e7e2469
1 (declaim (optimize speed))
3 (eval-when (:compile-toplevel :execute)
4 (if (and (boundp '*frob-macro-policy*)
5 (eq (symbol-value '*frob-macro-policy*) t))
6 (set-macro-policy '((speed 0))))
7 ;; RANDOM-EYES is purely a "macro helper" and should never generate efficiency
8 ;; notes. If all three situations were listed in the EVAL-WHEN - presumably
9 ;; because there are uses of RANDOM-EYES in the generated code- there would be
10 ;; an efficiency note regarding the code compiled into the fasl,
11 ;; but no note about the inefficiency of the in-memory code.
12 ;; Problem is, that's somewhat difficult to check for in an assertion.
13 (defun random-eyes (x) (length (string x))))
15 ;; All these macros use generic + which is "inefficient"
16 (defmacro fruitbat (arg)
17 `(cons ,arg ,(+ (random-eyes arg) 100)))
19 ;; Here we're just going to assert that no efficiency note is
20 ;; produced regarding the fact that FOO-EXPANDER uses GENERIC+.
21 (define-compiler-macro foo-expander (&whole form x)
22 (if (constantp x)
23 (+ (eval x) 19)
24 form))
26 (defun way1 (x)
27 (fruitbat x))
29 (defun way2 (x)
30 (macrolet ((local-foo (arg)
31 `(cons ,arg ,(+ (random-eyes arg) 100))))
32 (local-foo x)))
34 (macrolet ((local-foo (arg)
35 `(cons ,arg ,(+ (random-eyes arg) 100))))
36 (local-foo *print-base*))