I'm learning how the macro system in Scheme works and I'm trying to make my code look more JavaScript-y. So I thought I would start with the function
macro. This is how I want a function definition to look:
(function id (x) x)
It should expand to the following:
(define (id x) x)
So I write a macro as follows:
(define-syntax function
(lambda (name args . body)
`(define (,name ,@args) ,@body)))
However when I use it I get the following error (in Chicken Scheme):
Error: during expansion of (define ...) - in `define' - lambda-list expected: (define ((function id (x) x) . #<procedure (rename sym1348)>) #<procedure (compare s11400 s21401)>)
Call history:
<syntax> (function id (x) x)
<eval> (##sys#cons (##core#quote define) (##sys#cons (##sys#cons name args) body))
<eval> (##sys#cons (##sys#cons name args) body)
<eval> (##sys#cons name args) <--
Where am I going wrong? In addition how do I read such error messages to be able to debug the program myself?