From: Robert E. Brown <bbrown@sp...> - 2004-01-31 03:12:46
I may have mentioned this SBCL behavior before, but I'll do so again, since
I can't seem to locate an email in my outbox about it.
The following code:
(defvar *foo* nil)
(declaim (type (or null function) *foo*))
(defun a () (when *foo* (funcall *foo*)))
(defun b () (if *foo* (funcall *foo*)))
(defun c () (and *foo* (funcall *foo*)))
generates 3 compiler messages, one for each of A, B, and C:
; note: unable to
; optimize away possible call to FDEFINITION at runtime
; due to type uncertainty:
; The first argument is a (OR NULL FUNCTION), not a FUNCTION.
In each case, SBCL fails to deduce that *FOO* can only be invoked when it is
not NIL. I would have guessed that Python's type inferencer could handle
this sort of thing.
Maybe the essential feature here is that the type restriction is based on an
expression in a conditional test. Perhaps Python never looks at test
expressions to extract type information. Is this what's going on?
Get latest updates about Open Source Projects, Conferences and News.