From: Steve Levine <sjlevine@mi...>  20140423 23:54:37

Hi everybody, First, let me thank you for all your hard work on SBCL! I have a question about SBCL optimizations for slot types in classes. I've noticed that when using (withslots ...) in a certain way, I seem to get a lot of "unable to optimize" notices. Here's a toy example: (defclass A () ((m_num :type fixnum :initform 2))) (defmethod f ((a A)) (withslots (m_num) a (incf m_num))) Upon compiling function f, I receive a number of optimization notices: ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a NUMBER, not a FLOAT. ; ; note: unable to ; associate +/+ of constants ; due to type uncertainty: ; The first argument is a NUMBER, not a RATIONAL. ; ; note: unable to ; associate +/ of constants ; due to type uncertainty: ; The first argument is a NUMBER, not a RATIONAL. ; ; note: forced to do GENERIC+ (cost 10) ; unable to do inline fixnum arithmetic (cost 1) because: ; The first argument is a T, not a FIXNUM. ; The result is a (VALUES NUMBER &OPTIONAL), not a (VALUES FIXNUM &REST T). ; unable to do inline fixnum arithmetic (cost 2) because: ; The first argument is a T, not a FIXNUM. ; The result is a (VALUES NUMBER &OPTIONAL), not a (VALUES FIXNUM &REST T). ; etc. I'm new to the SBCL flavor of common lisp, and may be misinterpreting the above notices. It seems to me that perhaps SBCL is not inferring that m_num is a fixnum, and hence can't optimize (inc f ...) fully. Is that correct? Perhaps not though, because adding (declare (fixnum m_num)) right before the (incf ...) doesn't seem to help. If so, any advice or pointers to improve the optimization would be greatly appreciated! Thanks so much! Best regards, Steve 