Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Common Lisp's #. in Racket
#lang racket
#.(begin (define x 30) '(void))
'(1 2 #.x))
#lang racket
(require (prefix-in r: racket))
(define ns (make-base-namespace))
(define (make-rt)
(make-readtable (current-readtable)
(λ (ch in . args)
(define expr (r:read in))
(define r (eval expr ns))
(define (read . args)
(parameterize ([current-readtable (make-rt)])
(apply r:read args)))
(define (read-syntax a b . args)
(parameterize ([current-readtable (make-rt)])
(r:read-syntax a b)))
;(read (open-input-string "(1 2 #.(+ 10 20))")) ;; produces '(1 2 30)
(provide read read-syntax make-rt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment