[plt-scheme] How to use a custom procedure as read?

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Mon Sep 29 21:30:41 EDT 2008

Ali wrote:
> Hi,
> I'm sorry to ask this question, since it has been asked before, but I 
> could not make any sense of it at all.
> My query is fairly simple, and after an hour or two of searching and 
> trial and error, I hope I can get the answer an easier way here!
> Looked in the reference, this seems to be what I want, but all I'm not 
> sure exactly how to use it.
> http://docs.plt-scheme.org/syntax/reader-helpers.html#(part._module-reader) 
> <http://docs.plt-scheme.org/syntax/reader-helpers.html#%28part._module-reader%29>
> Read this and seemed to make sense, but not sure how to apply it to my 
> problem.
> http://www.htus.org/Book/Staging/how-to-use-modules/
> I believe the answer is in here, but again, I haven't been able to get 
> it working.
> http://groups.google.com/group/plt-scheme/browse_thread/thread/8aabfc15e0a392df/8a67d42dfcdadcae?lnk=gst&q=reader#8a67d42dfcdadcae 
> <http://groups.google.com/group/plt-scheme/browse_thread/thread/8aabfc15e0a392df/8a67d42dfcdadcae?lnk=gst&q=reader#8a67d42dfcdadcae>
> Problem:
> I've got a Scheme procedure which I would like to temporarily use as 
> the read procedure, eg.
> (swap-the-reader-in)
> ... code using custom reader ...
> (swap-the-reader-out)
> ... normal reader again ...
> My MzScheme version is 372. I'd be really grateful for an example of 
> how to temporarily use a custom procedure as the reader function.
> Thanks, Al

You should put `code using custom reader' in a separate module that use 
your own reader, and rest code in other (normal) modules. Hope you can 
figure out the rest on your own by reading the docs.


Posted on the users mailing list.