If I have a function that accepts function argument, for optimization purposes I can declare it to be a function, let's say
(defun foo (f)
(declare (type function f))
...)
However, I can be even more specific:
(defun foo (f)
(declare (type (function (double-float) double-float) f))
...)
i.e. telling that f will accept one double-float argument and return one double-float value. SBCL, however, seem to be able to perform a better optimization on the former and for the latter it says that it doesn't know if f is fdefinition (try to compile with (optimize (speed 3)) declaration to reproduce).
So, my questions are:
Am I doing something wrong? Especially If SBCL would do exactly the same thing for just
functionand(function ...)I would be OK with it, but it actually does worse. Or should it be considered a bug in SBCL?Is function type declaration in general useless in CL in terms of optimization for some reason?
SysInfo: SBCL 1.3.18