define-syntax

Sources for learning about Scheme Macros: define-syntax and syntax-rules

I've read JRM's Syntax-rules Primer for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of implementing a syntax transformer within define-syntax. I'm looking for two things, the first is more examples and explanations of syntax-rules...

Scheme Macro for nesting expressions

Can a macro be written in Scheme (with define-syntax, for example) which will take expressions like this: (op a b c d e f g h i j) And yield expressions like this as output? (op (op (op (op (op (op (op (op (op a b) c) d) e) f) g) h) i) j) Of course, for arbitrary lengths. I can't think of a way to do it, given some template like th...

How are vector patterns used in syntax-rules?

Hi, I have been writing Common Lisp macros, so Scheme's R5Rs macros are a bit unnatural to me. I think I got the idea, except that I don't understand how one would use vector patterns in syntax-rules: (define-syntax mac (syntax-rules () ((mac #(a b c d)) (let () (display a) (newline) (display d) (...

What, if any, is wrong with this definition of letrec in Scheme?

R5RS gives proposed macro definitions for library forms of syntax: http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-10.html#%_sec_7.3 Which also defines letrec, in a very complicated way, certainly not how I would define it, I would simply use: (define-syntax letrec2 (syntax-rules () ((letrec2 ((name val) ...) body bod...