[plt-scheme] reader macros

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Thu Jun 2 00:17:07 EDT 2005

I'm looking through the docs on the new reader macros, and am a little
fuzzy how to get them started.  How would I do something like adding a
new quote-like-char?  so for example if i wanted

(define fun1
  (fun2 ~( a b c)))

to be read in as

(define fun1
  (fun2 (super-quasi-quote ( a b c))))


the lisp version would be:
(set-macro-character #\~
  #'(lambda (stream char)
        (list (quote super-quasi-quote) (read stream t nil t))))

And i found in plt "make-readtable", so i think i start with something like:
(make-readtable #f #\~  {somesymbol}
    (lambda (char port)
         (list (quote super-quasi-quote) (read port #t `() #t))))
except read only can take 1 parameter, so maybe more like:
(make-readtable #f #\~  {somesymbol}
    (lambda (char port)
         (list (quote super-quasi-quote) (read port))))

but once i get this, how do i register the table so that the next
"(read)" will use the new transformation?



Posted on the users mailing list.