Alexey Dejneka <adejneka@...> writes:
> 13:34:25 <Krystof> because I can't think of a particularly good way to
> turn it off, as I think our IF optimizer isn't smart enough to
> subtract out NULL from the type in the true branch :/
> 13:34:35 <Krystof> at least, not in the general case. So things like
> 13:34:53 <Krystof> (let ((name (or (posix-getenv "FOO") (error)))
> 13:35:01 <Krystof> (pos (position #\: name))
> 13:35:16 <Krystof> don't get NAME to be blessed as a SIMPLE-BASE-STRING
> 13:35:53 <Krystof> and because NIL is a list and therefore valid as
> input to POSITION, sbcl whinges :-/
> Hmm. COMPILE-FILE on
> (defun foo ()
> (declare (optimize (speed 2)))
> (let ((name (or (posix-getenv "FOO") (error ""))))
> (position #\: name)))
> does not emit any notes for me (type check still may be performed if
> safety=3, because POSIX-GETENV may return an alien pointer).
Thanks for pointing me at my misdiagnosis.
What I think is actually happening, then, is that in fact the type
deriving mechanism isn't the problem.
The code in CLX that's giving me this optimization note is (in the
(defun getenv (name)
#+sbcl (sb-ext:posix-getenv name))
(defun get-default-display ()
(let* ((name (or (getenv "DISPLAY") (error "foo")))
(colon-i (position #\: name))
And the problem is that, even with *DERIVE-FUNCTION-TYPES*, the types
of the functions we compile in the same file aren't available, because
they're only put into the INFO database at load time, so when
GET-DEFAULT-DISPLAY is compiled, the compiler thinks it doesn't know
enough about GETENV.
This, then, would be another obstacle to be overcome in the quest for
squeezing maximal speed out of COMPILE-FILE.
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)