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
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/
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