Re: Distinguish between procedure and macro
Kjetil Svalastog Matheussen <[email protected]> Fri, 23 Mar 2007 17:48:20 +0100 (CET)
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 23 Mar 2007, Daniel Sadilek wrote:
> Hello,
>
> is it possible to find out if an identifier is bound to an ordinary
> procedure or to a syntactic form?
>
> My first guess was (type-of <identifier>) which raises an error if
> called with an identifier of a syntactic form. I tried to distinguish
> between procedure and syntactic form by catching that error:
>
> (define-syntax syntactic-form?
> (syntax-rules ()
> ((_ identifier)
> (with/fc
> (lambda (error-record error-k)
> #t)
> (lambda ()
> (type-of identifier)
> #f)))))
>
> But the error continuation doesn't get called.
>
Not very nice, but this works:
(define-macro (procedure2? symbol)
`(with-failure-continuation
(lambda (error-record error-k)
#f)
(lambda ()
(eval ',symbol))))
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV