[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntax-case oddity

Quoting Francisco Solsona:
> (define-syntax (:optional stx)
> 	  (syntax-case stx ()
> 		       [(_ val default)
> 			(begin
> 			  (unless (list? (syntax val))
> 				  (raise-syntax-error #f "expected a list" stx (syntax val)))
> 			  (syntax (if (null? val) default (car val))))]))
> but it hates the `(list? (syntax val))' thing:
> > (:optional '(foo bar) 'foobar)
> STDIN::3500: :optional: expected a list at: (quote (foo bar)) in: (:optional (quote (foo bar)) (quote foobar))
> Am I missing something?

A syntax object is not a list, even if it encapsulates list structure:

 > (syntax (1 2 3))

(This is different from Chez.)

The "stx.ss" library of "syntax" provides handy functions like
`stx-list?', though:

 > (require (lib "stx.ss" "syntax"))
 > (stx-list? (syntax (1 2 3)))