Optimizing Lisp
I have some code I'm trying to optimize, and I have some questions about the kinds of optimizations LispWorks can do with (speed 3) (safety 0) (debug 0) etc. * Does it help to (declare (type ...)) of a symbol (either lexical or special) if that symbol refers to an obj (either struct or CLOS)? * Does it help to (declare (ftype ...)) for functions? Is it possible for methods? * Does it help to declare :type for CLOS slots? * Is it insane to use CLOS objects and methods when speed is important? The alternative would be defuns with either case or typecase, which is theoretically the same but probably much easier for Lisp to optimize--esp since there's no multi-method overhead, etc. I've been running timing tests and I've been looked at disassembled code, but I'm learning as I go and official feedback would help. ps: For this project I've ported tens of thousands of lines of code to just a couple thousand lines of Lisp. The reason for the dramatic reduction is that the old code basically implemented an interpreter for user-defined formulas. In the Lisp version everything--including user-defined formulas--runs as native code. Performance is important because one run of the program can calculate tens of millions of values. Native code should make it smaller *and* faster... But only, I think, if optimizations are in place. The interpreter was an interpreter, but it was reasonably well optimized...