From: Tin Gherdanarra
Subject: boundp for lexical bindings?
Date: 
Message-ID: <4ssougF10vu35U1@mid.individual.net>
Is there a boundp for lexical bindings?

(let ((foo 'bar)) (boundp 'foo)) gives nil.
(let ((foo 'bar)) (mystery-functions 'foo)) gives true,
but is there a function that works like mystery-function?

Thanks
Tin
-- 
Lisp kann nicht kratzen, denn Lisp ist fluessig

From: Pascal Costanza
Subject: Re: boundp for lexical bindings?
Date: 
Message-ID: <4st7gmF10rkhsU1@mid.individual.net>
Tin Gherdanarra wrote:
> Is there a boundp for lexical bindings?
> 
> (let ((foo 'bar)) (boundp 'foo)) gives nil.
> (let ((foo 'bar)) (mystery-functions 'foo)) gives true,
> but is there a function that works like mystery-function?

No, you have to implement this yourself.

Roughly like this:

(defvar +unbound-value+ (gensym "UNBOUND"))

(defun lboundp (variable)
   (not (eq variable +unbound-value+)))

(defmacro llet (&whole form (&rest bindings) &body body)
   `(let ,(loop for binding in bindings
                if (consp binding)
                collect binding
                else if (symbolp binding)
                collect `(,binding +unbound-value+)
                else (error "Invalid binding ~S in ~S."
                            binding form)
      ,@body))

[Untested.]


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Tin Gherdanarra
Subject: Re: boundp for lexical bindings?
Date: 
Message-ID: <4sv09rF112hlnU1@mid.individual.net>
Pascal Costanza wrote:
> Tin Gherdanarra wrote:
> 
>> Is there a boundp for lexical bindings?
>>
>> (let ((foo 'bar)) (boundp 'foo)) gives nil.
>> (let ((foo 'bar)) (mystery-functions 'foo)) gives true,
>> but is there a function that works like mystery-function?
> 
> 
> No, you have to implement this yourself.
> 
> Roughly like this:
> 
> (defvar +unbound-value+ (gensym "UNBOUND"))
> 
> (defun lboundp (variable)
>   (not (eq variable +unbound-value+)))
> 
> (defmacro llet (&whole form (&rest bindings) &body body)
>   `(let ,(loop for binding in bindings
>                if (consp binding)
>                collect binding
>                else if (symbolp binding)
>                collect `(,binding +unbound-value+)
>                else (error "Invalid binding ~S in ~S."
>                            binding form)
>      ,@body))
> 
> [Untested.]
> 
> 
> Pascal
> 

Thanks, Pascal (:
This is exactly what I was afraid of.
I'm glad that - by sheer luck - I have
control over local argument lists.

-- 
Lisp kann nicht kratzen, denn Lisp ist fluessig