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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to