[racket] Exposition via macro

From: Philipp Dikmann (philipp at dikmann.de)
Date: Fri Jan 4 16:17:08 EST 2013

Thanks to both of you! Those are two nice solutions that I didn't know 
about.

On 04.01.13 21:21, Vincent St-Amour wrote:
> If the original and user code are in different modules, you can use
> `provide' with `rename-out' or `require' with `rename-in'.
>
> Vincent
>
>
> At Fri, 04 Jan 2013 20:52:36 +0100,
> Philipp Dikmann wrote:
>> 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
>>
>> ____________________
>>    Racket Users list:
>>    http://lists.racket-lang.org/users


Posted on the users mailing list.