Re: programmatically determine if argument is list compatible to a given lambda list
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Mon, 30 Apr 2007 00:38:31 +0200
Alan Crowe wrote:
Pascal Costanza <pc@xxxxxxxxx> writes:
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?
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)))
Seeing Pascal's handler for program-error made me think of
the third value from COMPILE
CL-USER> (let ((*error-output* (make-broadcast-stream)))
(compile nil '(lambda() ((lambda(&key a b )nil) :a 3 ))))
#<Function "LAMBDA NIL" {48A60019}>
T
NIL <-- OK so error=nil
CL-USER> (let ((*error-output* (make-broadcast-stream)))
(compile nil '(lambda() ((lambda(&key a b )nil) :a 3 :c 3))))
#<Function "LAMBDA NIL" {48AA49D1}>
T
T <-- :c not declared to error=T
I specifically went for coerce instead of compile because coerce may give you interpreted code while compile is required to do at least minimal compilation. Since these are one-off functions by definition, interpreted code is more efficient in this case - the overhead of compilation is not justified here, especially in implementations with slow compilers (like SBCL).
Having said that, I have to admit that I would have probably overlooked the additional return values of compile anway, so thanks for the hint. ;)
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/
.
- 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
- 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: Alan Crowe
- programmatically determine if argument is list compatible to a given lambda list
- Prev by Date: Re: CL Scaling for High Traffic Web Sites
- Next by Date: Re: What are the domains that lisp doesn't fit int?
- 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):
Relevant Pages
|