I am using old Common Lisp code written by others, which includes the following lines at the beginning of several functions:
(declare (ftype (function (&rest float) float) + - * min max))
My understanding is that the purpose of this is to tell the compiler that the five functions listed at the end of the form will only be passed to floats. The compiler can use this information to create more efficient code.
Some Lisp do not complain about this declaration (ABCL, CCL, ECL, LispWorks, CLISP), but SBCL will not accept this declaration in the default configuration. SBCL can be made to accept it by posting
(unlock-package 'common-lisp)
in the .sbclrc initialization file. This is what I did last year or so. I assume this is necessary because this package has +, -, etc., and the code modifies the declarations of these functions.
My question is: can a function type declaration of built-in functions, such as + and min, have a beneficial effect on compiled code in SBCL? (If possible, why is SBCL complaining about these ads by default?) Would it be better to delete such ads like ftype and then get rid of the unlock-package in .sbclrc?
Thanks.
source share