modify release.sh for new SourceForge urls
[sbcl.git] / tests / macro-policy-test.lisp
blobb67bfbf2b7ec6ca7c6c686ae84d38fc0ff857ab5
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 (define-compiler-macro foo (&whole form x)
20 (if (constantp x)
21 (+ (eval x) 19)
22 form))
24 (defun way1 (x)
25 (fruitbat x))
27 (defun way2 (x)
28 (macrolet ((local-foo (arg)
29 `(cons ,arg ,(+ (random-eyes arg) 100))))
30 (local-foo x)))
32 (macrolet ((local-foo (arg)
33 `(cons ,arg ,(+ (random-eyes arg) 100))))
34 (local-foo *print-base*))