Re: programmatically determine if argument is list compatible to a given lambda list
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Sun, 29 Apr 2007 02:56:10 +0200
jimka wrote:
even after getting rid of the lexical binding problem, i'd like to
tell sbcl that i'm not interesting in
seeing the other comments. any ideas?
(defun callable-as (arg-list lambda-list)
(declare (sb-ext:muffle-conditions sb-ext:compiler-note))
(handler-case (apply (coerce `(lambda ,lambda-list
t)
'function)
arg-list)
(program-error () nil)))
TYPE> (callable-as '(3) '(x))
; #'(LAMBDA (TYPE::X) T)
;
; caught STYLE-WARNING:
; The variable X is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
T
TYPE>
Hm, maybe:
(defun callable-as-p (arg-list lambda-list)
(handler-case
(apply
(handler-bind ((style-warning #'muffle-warning))
(locally (declare (optimize (safety 3)))
(coerce `(lambda ,lambda-list t) 'function)))
arg-list)
(program-error () nil)))
The coercion happens at runtime, so the sb-ext:muffle-conditions declaration probably doesn't have any effect here, because the latter only applies at compile time.
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/
.
- Follow-Ups:
- References:
- programmatically determine if argument is list compatible to a given lambda list
- From: jimka
- Re: programmatically determine if argument is list compatible to a given lambda list
- From: Pascal Costanza
- Re: programmatically determine if argument is list compatible to a given lambda list
- From: jimka
- Re: programmatically determine if argument is list compatible to a given lambda list
- From: Pascal Costanza
- Re: programmatically determine if argument is list compatible to a given lambda list
- From: jimka
- Re: programmatically determine if argument is list compatible to a given lambda list
- From: jimka
- programmatically determine if argument is list compatible to a given lambda list
- Prev by Date: Re: What are the domains that lisp doesn't fit int?
- Next by Date: Re: pattern-matching in LISP?
- Previous by thread: Re: programmatically determine if argument is list compatible to a given lambda list
- Next by thread: Re: programmatically determine if argument is list compatible to a given lambda list
- Index(es):