[racket] Evaluation at compile time

From: Tony Garnock-Jones (tonyg at ccs.neu.edu)
Date: Wed Jun 8 13:23:15 EDT 2011

Hi all,

I would like to read in a JSON file at compile time, converting it to 
SJSON, to avoid doing so at runtime. Here's what I've come up with so 
far. Is there a more elegant way? Perhaps an (at-compile-time <expr>) 
form? -- Tony

#lang racket
(require (for-syntax "json-parsing.ss")) ;; Thanks, Neil!
(define-syntax loaded-uci-descriptions
   (lambda (stx)
     (syntax-case stx ()
       ((_) #`(quote #,(call-with-input-file "uci-descriptions.js"
			(lambda (f) (json->sjson f))))))))
(define uci-descriptions (loaded-uci-descriptions))
(provide uci-descriptions)


Posted on the users mailing list.