[plt-scheme] Problem with define-syntax on 200
(syntax (binding ...)) produces a syntax object represeting a list, not
a list itself. Use syntax->list to unwrap the list without unwrappnig
the elements, as shown below in your code.
Paul
At Tue, 30 Jul 2002 21:56:28 -0500, Blake McBride wrote:
> ------------------------------------------------------------------------------
>
> Greetings,
>
> I took a define-syntax definition for 'do' from "The Scheme
> Programming Language" by Dybvig and tried it under DrScheme
> version 200. The definition and error is as follows:
>
> (define-syntax debug-do
> (lambda (x)
> (syntax-case x ()
> ((_ (binding ...) (test res ...) exp ...)
> (with-syntax ((((var val update) ...)
> (map (lambda (b)
> (syntax-case b ()
> ((var val)
> (syntax (var val var)))
> ((var val update)
> (syntax (var val update)))))
(syntax->list
> (syntax (binding ...)))))
)
> (syntax (let doloop ((var val) ...)
> (if test
> (begin (if #f #f) res ...)
> (begin exp ... (doloop update ...))))))))))
>
> (define try
> (lambda (m)
> (debug-do ((i 0 (+ i 1)))
> ((> i m) 88)
> (display i)
> (newline))))
>
>
> 'try' works fine with the real 'do' but gives the following error with
> 'debug-do'
> at definition time:
>
> map: expects type <list> as 2nd argument, given:
> #<syntax:C:\Scheme-debugger\debugger.scm:266:28>; other arguments were:
> #<procedure:...ger\debugger.scm:260:28>
>
> (debugger.scm is a debugger I'm working on - It actually works!)
>
> I need this code to work for real. It's not just an exercise for me.
> Your help is appreciated.
>
> --blake
>
> -------
> Download source code to my Dynace Object Oriented
> Extension to C from http://algorithms.us
>
> ------------------------------------------------------------------------------
> Greetings,
> I took a define-syntax definition for 'do' from "The Scheme
> Programming Language" by Dybvig and tried it under DrScheme
> version 200. The definition and error is as follows:
> (define-syntax debug-do
> (lambda (x)
> (syntax-case x ()
> ((_ (binding ...) (test res ...) exp ...)
> (with-syntax ((((var val update) ...)
> (map (lambda (b)
> (syntax-case b ()
> ((var val)
> (syntax (var val var)))
> ((var val update)
> (syntax (var val update)))))
> (syntax (binding ...)))))
> (syntax (let doloop ((var val) ...)
> (if test
> (begin (if #f #f) res ...)
> (begin exp ... (doloop update ...))))))))))
> (define try
> (lambda (m)
> (debug-do ((i 0 (+ i 1)))
> ((> i m) 88)
> (display i)
> (newline))))
> 'try' works fine with the real 'do' but gives the following error with 'debug-do'
> at definition time:
> map: expects type <list> as 2nd argument, given: #<syntax:C:\Scheme-debugger\debugger.scm:266:28>; other arguments were: #<procedure:...ger\debugger.scm:260:28>
> (debugger.scm is a debugger I'm working on - It actually works!)
> I need this code to work for real. It's not just an exercise for me.
> Your help is appreciated.
> --blake
>
> -------
> Download source code to my Dynace Object Oriented
> Extension to C from http://algorithms.us