[racket] Is there a way to specify a reader for the repl for a language?

From: Alexander D. Knauth (alexander at knauth.org)
Date: Fri Oct 24 23:56:00 EDT 2014

Do you mean something like this?:

(provide (rename-out [-#%module-begin #%module-begin]))

(define-syntax-rule (-#%module-begin form ...)
  (#%module-begin
   (module configure-runtime racket/base
     (current-prompt-read
      (let ([old-prompt-read (current-prompt-read)])
        (lambda ()
          (parameterize ([current-readtable (make-readtable-for-my-lang)])
            (old-prompt-read))))))
   form ...))


On Oct 24, 2014, at 11:19 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> I think a `configure-runtime` submodule (in the expansion of any module
> using the language) is the right place for this kind of configuration.
> 
> The `configure-runtime` submodule is similar to `main`, it that it is
> only used when the enclosing module is the main module of a program.
> 
> Instead of a direct `(current-readtable ...)`, I think you'll want a
> direct `(current-prompt-read ...)`, where the prompt read handler uses
> `(parameterize ([current-readtable ...]) (read-syntax ...))`.
> 
> At Fri, 24 Oct 2014 22:56:37 -0400, "Alexander D. Knauth" wrote:
>> Is there a way to specify a reader for the repl for a language?
>> 
>> One bad way to do this would be to modify #%module-begin to include
>> (current-readtable (make-readtable-for-my-lang))
>> or something like that.
>> See
>> https://github.com/greghendershott/rackjure/pull/46
>> https://github.com/greghendershott/rackjure/pull/46#issuecomment-60378324
>> 
>> One problem with this is that if this module is required from a module without 
>> this language, it would affect that module’s current-readtable.  
>> 
>> So is there a better solution, and if there’s not, would it be possible to add 
>> it?
>> 
>> 
>> 
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141024/fbecd6e5/attachment-0001.html>

Posted on the users mailing list.