3 ms·
The reason I didn't list it is because there's so many different ways to do it. The optimization declaration can be made globally, or per-file; declaring the t
by white-flame 9y ago
The reason I didn't list it is because there's so many different ways to do it.
The optimization declaration can be made globally, or per-file; declaring the type of the foo function (including parameters & return values) externally will fully cover this function without having anything additional in the body; there's helper macros to explicitly manage static types, etc.
So the type declarations don't need to be intrusive into the expressions themselves, and can be as transparent as you want. Of course, type inference also means that you don't have to specify every single type, while still getting the speed & checking benefit of fully typed code.
- omaranto 9y agoCould you show a way to get that code to be generated without any declarations in the body of the function? I tried something like: (declaim (ftype (function (fixnum fixnum) fixnum) foo) (optimize (safety 0))) (defun foo (m n) (* (1+ m) n)) That didn't optimize as fully.
- white-flame 9y agoYou forgot (optimize (speed 3))
- omaranto 9y agoI did try with speed 3. Do you mean that: (declaim (ftype (function (fixnum fixnum) fixnum) foo) (optimize (safety 0) (speed 3)) (defun foo (m n) (* (1+ m) n)) should have produced the optimized code (without any generic-*)? It didn't in my testing on SBCL 1.3.18.