[plt-scheme] problem with example macro
michael rice skrev:
> Noticed this about the first macro given in
> "Syntax-rules Primer for the Merely Eccentric" in the
> Macro section of schematics:cookbook.
>
> Hope it's not something I'm doing wrong.
>
> Michael
>
>
> (define-syntax nth-value
> (syntax-rules ()
> ((nth-value n values-producing-form)
> (call-with-values
> (lambda () values-producing-form)
> (lambda all-values
> (list-ref all-values n))))))
>
> =================================
>
> Welcome to DrScheme, version 360.
> Language: Swindle.
>> (nth-value 3 '(a b c d e f))
> . list-ref: index 3 too large for list: ((a b c d e
> f))
Your values-producing-form is '(a b c d e f).
That produces 1 value. This explains, why the
error say index 3 is too large.
Try
(nth-value 3 (values 'a 'b 'c 'd 'e 'f))
--
Jens Axel Søgaard