Building Little Languages with Macros
By Matthias Felleisen, Robert Bruce Findler, Matthew Flatt and and Shriram Krishnamurthi, April 01, 2004
Source Code Accompanies This Article. Download It Now.
Pattern-based macros in Scheme can express interesting language extensions.
Apr04: Building Little Languages With Macros
<b>(a)</b>
(define-cbr-as-cbv do-f (arg ...)
() body)
<b>(b)</b>
(define-cbr (f a b)
(swap a b))
<b>(c)</b>
(begin
(define-cbr-as-cbv do-f (a b)
() (swap a b))
(define do-f . . .))
<b>(d)</b>
(begin
(define-cbr-as-cbv do-f ()
((a get<sub>1</sub> set<sub>1</sub>) (b get<sub>2</sub> set<sub>2</sub>)) (swap a b))
(define do-f . . .))
Example 10: Replacement for ???.