[racket] Compile-time evaluation

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Mon Jul 29 21:44:57 EDT 2013

On Mon, Jul 29, 2013 at 1:53 PM, Vincent St-Amour <stamourv at ccs.neu.edu> wrote:
> Here's a quick solution:
>
>     #lang racket
>
>     (define-syntax-rule (hash-dot e)
>       (let-syntax ([computed-e (lambda (stx) (datum->syntax #'e e))])
>         (computed-e)))
>
>     (hash-dot (+ 2 3))
>

In CL, #. is read-time, not compile-time, evaluation, so this isn't
quite the same.  It would be easy to create a read-table that enabled
this, though.  You'd have to make some decision about what environment
the read-time expression sees -- I don't know what CL does here.

Sam

Posted on the users mailing list.