Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Lisp > Re: Any program...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 8 Topic 12466 of 13603
Post > Topic >>

Re: Any programmable way to ask whether a symbol has been proclaimed special?

by Kent M Pitman <pitman@[EMAIL PROTECTED] > May 12, 2008 at 11:38 PM

Juho Snellman <jsnell@[EMAIL PROTECTED]
> writes:

> Chris Barts <chbarts+usenet@[EMAIL PROTECTED]
> writes:
> > > (defun pervasively-special-p (var)
> > >   (values
> > >     (ignore-errors ;in case binding a constant doesn't work
> > >       (eval `(let ((,var nil))
> > >                (declare (special ,var))
> > >                (let ((,var t))
> > >                  (symbol-value ',var)))))))
> [...]
> > Except this fails on SBCL:
> > 
> > {begin transcript:
> > CL-USER> (pervasively-special-p '*print-base*)
> [...]
> > OK, the warnings are expected by design (SBCL is a bit... chatty) but
> > shouldn't the value be T regardless? Is this a bug in SBCL? I'm
> > running SBCL 1.0.6.
> 
> No, it's not an SBCL bug. The code is invoking at least two bits of
> undefined behaviour:
> 
>   * Declaring a symbol in CL special (11.1.2.1.2).

Yep, that's what it says.  Still, not that it matters because it's just
my personal point of view, I always thought of that as forbidding you 
from declaring system special that wasn't already special, that is, from
changing the behavior of a system-supplied symbol.  

>   * Binding the value of *print-base* to NIL and T, when it's defined
>     by the spec to be a radix (1.4.4.22).

You're just no fun. :)

Ok, I'll give it another go.  This should avoid a bunch of those details
everyone's nagging about.

(defun pervasively-special-p (var)
  (check-type var symbol "a variable name")
  (if (eq (symbol-package var) (load-time-value (find-package "CL")))
      (and (boundp var)
           (let* ((name (symbol-name var))
                  (n-chars (length name)))
             (and (> n-chars 0)
                  (eql (char name 0) #\*)
                  (eql (char name (- n-chars 1)) #\*)
                  :so-it-would-seem)))
     (values
       (handler-bind ((warning #'(lambda (warning)
                                   (when (find-restart 'muffle-warning
warning)
                                     (muffle-warning warning)))))
         (ignore-errors ;in case binding a constant doesn't work
           (eval `(let ((,var nil))
                    (declare (special ,var))
                    (let ((,var t))
                      (symbol-value ',var)))))))))
 




 8 Posts in Topic:
Any programmable way to ask whether a symbol has been proclaimed
usenet2.3.CalRobert@[EMAI  2008-05-11 21:20:30 
Re: Any programmable way to ask whether a symbol has been procla
Kent M Pitman <pitman@  2008-05-12 02:19:25 
Re: Any programmable way to ask whether a symbol has been procla
Chris Barts <chbarts+u  2008-05-12 17:27:41 
Re: Any programmable way to ask whether a symbol has been procla
Juho Snellman <jsnell@  2008-05-13 03:32:22 
Re: Any programmable way to ask whether a symbol has been procla
Kent M Pitman <pitman@  2008-05-12 23:38:20 
Re: Any programmable way to ask whether a symbol has been procla
jcornez@[EMAIL PROTECTED]  2008-05-16 06:57:30 
Re: Any programmable way to ask whether a symbol has been procla
rpw3@[EMAIL PROTECTED] (  2008-05-12 03:08:26 
Re: Any programmable way to ask whether a symbol has been procla
Duane Rettig <duane@[E  2008-05-12 08:17:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 2:18:00 CDT 2008.