Comment 3 for bug 922952

Revision history for this message
Douglas Katzman (dougk) wrote : Re: [Bug 922952] Re: KEYWORDP should be Foldable

I'd rather see type inferences for non-pathological code improved, than
inferences made worse assuming all hackers write pathological code.
At any rate, the compiler should be willing to call user-defined
'(SATISFIES foo) predicates, let alone KEYWORDP, under some compilation
policy.
See bug below, given that TYPE-OF and TYPEP are declared foldable.

This is SBCL 1.0.54.0-185b926, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (defvar +foo+ 'some-symbol)
+FOO+
* (defun what1 () (assert (eq (type-of +foo+) 'symbol)))
WHAT1
* (defun what2 ()

  (let ((s +foo+))

    (unintern s (symbol-package s))

    (import s 'keyword))

  (what1))
WHAT2
* (what1)
NIL
* (what2) ; oops, it's a KEYWORD now!

debugger invoked on a SIMPLE-ERROR:
  The assertion (EQ (TYPE-OF +FOO+) 'SYMBOL) failed.

On Sat, Jan 28, 2012 at 10:14 AM, Paul Khuong <email address hidden> wrote:

> The comment describing FOLDABLE is accurate, btw. Unfortunately, the
> issue with keywords is a bit more complicated. I'm not comfortable
> considering symbols that appear in source forms as literal. Moreover,
> even if they were literal values, it seems strange to disallow unintern,
> but allow (setf symbol-value) or (setf symbol-function).
>
>