You can make the compiler print messages which will help you to optimize your code. You add suitable
:explain
declarations, recompile the code, and check the output.
The full syntax of the
:explain
declaration is documented under
cl:declare
in the
LispWorks Reference Manual
.
Various keywords allows you to see information about compiler transformations depending on type information, allocation of floats and bignums, floating point variables, function calls, argument types and so on. Here is a simple example:
(defun foo (arg)
(declare (:explain :variables) (optimize (float 0)))
(let* ((double-arg (coerce arg 'double-float))
(next (+ double-arg 1d0))
(other (* double-arg 1/2)))
(values next other)))
;;- Variables with non-floating point types:
;;- ARG OTHER
;;- Variables with floating point types:
;;- DOUBLE-ARG NEXT
Note: the LispWorks IDE allows you to distinguish compiler optimization hints from the other output of compilation, and also helps you to locate quickly the source of each hint. For more information see the chapter "The Output Browser" in the Common LispWorks User Guide .