Re: programmatically determine if argument is list compatible to a given lambda list



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

Alan Crowe
Edinburgh
Scotland
.