Consider (define/memoized (a b c d) form0 form1 form2) . body allows the body to consist of more than one form. Without the dot, syntax define/memoized would accept bodies of one form only, that is (define/memoized (a b c d) form0) would match, but (define/memoized (a b c d) form0 form1 form2) would not match. With the dot (define/memoized (a b c d) form0 form1 form2) matches too.
Another way to achieve the same is: (define-syntax define/memoized (syntax-rules () ((_ (name . args) form ... expr) (define name (memoize (lambda args form ... expr)))))) or (define-syntax define/memoized (syntax-rules () ((_ (name arg ...) form ... expr) (define name (memoize (lambda (arg ...) form ... expr)))))) Hope this helps. Jos -----Original Message----- From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of Pedro Caldeira Sent: domingo, 13 de marzo de 2016 16:05 To: Racket Users Subject: [racket-users] Pattern Matching in Macros | Meaning of dot Hello everyone, Since I've discovered the concept of metaprogramming I've been quite interested in Racket and its syntax extension capabilities. While searching for a memoization syntax extension I found a macro whose pattern extension remained unclear. (define-syntax define/memoized (syntax-rules () ((_ (name . args) . body) (define name (memoize (lambda args . body)))))) With the memoization function being defined as such: (define (memoize f) (local ([define table (make-hash)]) (lambda args (dict-ref! table args (lambda () (apply f args)))))) What does the '.' mean in '(name . args)' and '. body'? In a call like (define/memoized (foo x y z) (displayln "bar"))) I would imagine that name would be matched to foo; (x y z) to args and body to (display ln "bar") but why do we use the '. body' in the lambda expression at the end? Thank you for your attention. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.