[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
syntax-case oddity
Hi all,
I was happily adding better error reporting to a very simple macro,
:optional, here's the final version:
(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? BTW, the following do works:
(define-syntax (:optional stx)
(syntax-case stx ()
[(_ val default)
(syntax (if (null? val) default (car val)))]))
> (:optional '(foo bar) 'foobar)
foo
poor error reporting, though:
> (:optional #f 'foobar)
car: expects argument of type <pair>; given #f
this is 200alpha9 (updated half an hour ago.)
Thanks,
--Francisco