[plt-dev] reader

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Mar 23 17:40:11 EDT 2010

At Tue, 23 Mar 2010 17:13:42 -0400, Matthias Felleisen wrote:
> Save the program below

As "foo.ss", I assume...

>  and run. See surprising error message. Change  
> language to #lang scheme and see same surprising error message. Why?

When you call `read', you generally don't expect arbitrary code to run.
Since `#reader' and `#lang' can make the reader load arbitrary code,
they're disabled by default. (They're specifically enabled for reading
code via `require' or `load'.)

To allow `read' on a module source, parameterize `read-accept-reader',
as in this "foo.ss":

  #lang scheme

  (parameterize ([read-accept-reader #t])
    (with-input-from-file "foo.ss" read))

Posted on the dev mailing list.