From: Bulent Murtezaoglu
Subject: specialp?
Date: 
Message-ID: <87fyqzsqn0.fsf@p4.internal>
Is there an ANSI CL way to figure out if a symbol denotes a (defvar'ed or 
declaimed special) top-level variable?  Something like specialp?  This 
apparently came up in a Turkish lisp group meeting.  With no CLtL2 
environments (or Franz's recent work), I couldn't think of any.  So I 
sketched the skeleton of a specialp function for the Turkish lispers 
that _experiments_ using eval:

(defun specialp (symbol) 
  (handler-bind ((warning #'muffle-warning)) ;; sbcl talks a lot  
    (eval `(let ((,symbol 25)) (boundp ',symbol))))) 

I suspect there might be better/more elegant ways though.  What do you 
think? 

thanks, 

BM

From: Wade Humeniuk
Subject: Re: specialp?
Date: 
Message-ID: <aBW4f.29771$Io.4801@clgrps13>
Bulent Murtezaoglu wrote:
> Is there an ANSI CL way to figure out if a symbol denotes a (defvar'ed or 
> declaimed special) top-level variable?  Something like specialp?  This 
> apparently came up in a Turkish lisp group meeting.  With no CLtL2 
> environments (or Franz's recent work), I couldn't think of any.  So I 
> sketched the skeleton of a specialp function for the Turkish lispers 
> that _experiments_ using eval:
> 
> (defun specialp (symbol) 
>   (handler-bind ((warning #'muffle-warning)) ;; sbcl talks a lot  
>     (eval `(let ((,symbol 25)) (boundp ',symbol))))) 
> 
> I suspect there might be better/more elegant ways though.  What do you 
> think? 
> 

Yeah, find the extension in your particular implementation of CL.
Compilers would need some functionality to know whether a var is
special, so it has to be in there somewhere.

LW, for one, has a function available.  With your Lisp your can usually
just find something if you use apropos and some good guessing.

CL-USER 10 > (apropos "SPECIAL-P")

SYSTEM::SYMBOL-SPECIAL-P -- #<function SYSTEM::SYMBOL-SPECIAL-P 201B76F2>
SYSTEM:DECLARED-SPECIAL-P$SYMBOL -- #<function SYSTEM:DECLARED-SPECIAL-P$SYMBOL 201B77BA>
SYSTEM:DECLARED-SPECIAL-P -- #<function SYSTEM:DECLARED-SPECIAL-P 201B777A>
COMPILER::*CHECK-GET-SPECIAL-POLICY* -- value: #<function (SUBFUNCTION 1 (TOP-LEVEL-FORM 
22)) 20A1EDAA>
COMPILER::IS-DECLARED-SPECIAL-P -- #<function COMPILER::IS-DECLARED-SPECIAL-P 20A057FA>
LEXICAL::VARIABLE-NON-LOCAL-SPECIAL-P -- #<function LEXICAL::VARIABLE-NON-LOCAL-SPECIAL-P 
2014F84A>
LEXICAL:VARIABLE-GLOBAL-SPECIAL-P -- #<function LEXICAL:VARIABLE-GLOBAL-SPECIAL-P 2014F812>
EDITOR::RE-SPECIAL-P -- #<function EDITOR::RE-SPECIAL-P 20BA738A>
WALKER:VARIABLE-SPECIAL-P -- #<function WALKER:VARIABLE-SPECIAL-P 2079EC72>
SYSTEM:DECLARED-SPECIAL-P$SYMBOL -- #<function SYSTEM:DECLARED-SPECIAL-P$SYMBOL 201B77BA>
SYSTEM:DECLARED-SPECIAL-P -- #<function SYSTEM:DECLARED-SPECIAL-P 201B777A>
SYSTEM:DECLARED-SPECIAL-P -- #<function SYSTEM:DECLARED-SPECIAL-P 201B777A>
SYSTEM:DECLARED-SPECIAL-P$SYMBOL -- #<function SYSTEM:DECLARED-SPECIAL-P$SYMBOL 201B77BA>

CL-USER 11 > (defvar test)
TEST

CL-USER 12 > (system:declared-special-p 'test)
T

CL-USER 13 > (system:declared-special-p 'bogus)
NIL

CL-USER 14 >

Wade
From: Edi Weitz
Subject: Re: specialp?
Date: 
Message-ID: <u64rvd8re.fsf@agharta.de>
On Tue, 18 Oct 2005 01:52:19 +0300, Bulent Murtezaoglu <··@acm.org> wrote:

> Is there an ANSI CL way to figure out if a symbol denotes a
> (defvar'ed or declaimed special) top-level variable?  Something like
> specialp?  This apparently came up in a Turkish lisp group meeting.
> With no CLtL2 environments (or Franz's recent work), I couldn't
> think of any.  So I sketched the skeleton of a specialp function for
> the Turkish lispers that _experiments_ using eval:
>
> (defun specialp (symbol) 
>   (handler-bind ((warning #'muffle-warning)) ;; sbcl talks a lot  
>     (eval `(let ((,symbol 25)) (boundp ',symbol))))) 
>
> I suspect there might be better/more elegant ways though.  What do
> you think?

Another variant:

  <http://groups.google.com/group/comp.lang.lisp/msg/87c67720e0e7cc35>


Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")