[racket] Exposition via macro

From: Philipp Dikmann (philipp at dikmann.de)
Date: Fri Jan 4 14:52:36 EST 2013

Hello everybody,

I'm trying to expose a module's functionality to the user via a macro 
that will let them use 'short-hand' names for the provided functions. 
Yet I want to keep the 'long' names inside the original code for 
clarity. The code below will not work - because of macro hygiene - but 
demonstrates the intention. How would you approach this?

#lang racket

(provide with-timesten)

(define (timesten x)
   (* x 10))

(define-syntax with-timesten
   (syntax-rules ()
     [(_ body ...) (let ([tt timesten])
                     (begin
                       body ...))]))

;; ... so the user can do:
(with-timesten
  (tt 1)
  (tt 2)
  (tt 3))

Best regards,
Philipp


Posted on the users mailing list.