[racket] module->language-info at repl

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Sep 1 16:32:43 EDT 2011

The `-I' flag just sets a module to `require' by default, so it's the
same issue as in Sam's question.

Probably you want to write "Z/main.rkt" itself in a language whose
runtime configuration is the same as for modules implemented with
`#lang Z'. See "racket/main.rkt" and "racket/base.rkt", for example,
which are implemented in the `racket/private' language.

At Thu, 01 Sep 2011 14:23:04 -0600, Jon Rafkind wrote:
> I changed #:info to
> 
> #:language-info #('Z/runtime configure 'dont-care)
> 
> And added Z/runtime.rkt with
> 
> #lang racket/base
> (provide configure)
> (define (configure . args)
>   (printf "called configure with ~a\n" args)
>   #f)
> 
> But the printf doesn't happen. Is the '-Iq Z' flag not the right incantation?
> 
> On 09/01/2011 01:43 PM, Matthew Flatt wrote:
> > Instead of `#:info', you want to specify `#:language-info'.
> >
> > The `#:info' hook is for things related to the *source* of a module in
> > the language, such as syntax coloring in DrRacket for a module that
> > start `#lang Z'. The plain `racket' REPL doesn't deal with the module's
> > source at all in that sense.
> >
> > The `#:language-info' hook is for things related to *running* a module
> > that starts `with `#lang Z'. When such a module is provided to
> > `racket', then `racket' uses `configure-runtime' before instantiating
> > the module.
> >
> > At Thu, 01 Sep 2011 13:01:48 -0600, Jon Rafkind wrote:
> >> More details on how my system is setup:
> >>
> >> 1. Make a directory for a new language called Z
> >> 2. Edit Z/lang/reader.rkt and put this in there
> >> #lang s-exp syntax/module-reader
> >>
> >> Z
> >>
> >> #:info z-info
> >>
> >> (define (z-info key default filter)
> >>   (printf "called z-info\n")
> >>   (filter key default))
> >>
> >> 3. Edit Z/main.rkt
> >> #lang racket/base
> >> (provide (all-from-out racket/base))
> >>
> >> 4. Run with the Z language
> >> $ PLTCOLLECTS=`pwd`:$PLTCOLLECTS racket -Iq Z
> >> Welcome to Racket v5.1.3.6.
> >> At this point I would expect it to say "called z-info" to try to set up the 
> >> runtime.
> >>
> >>
> >> On 09/01/2011 12:50 PM, Jon Rafkind wrote:
> >>> The repl doesn't seem to invoke the module language's get-info procedure. 
> My 
> >> #lang has a `get-info' procedure that is passed to the module-reader by 
> #:info
> >>> honu-info. get-info is defined as
> >>>
> >>> (provide honu-info)
> >>> (define (honu-info key default default-filter)
> >>>   (printf "get info for ~a\n" key)
> >>>   (case key
> >>>     [(color-lexer) (dynamic-require 'honu/core/read
> >>>                                     'color-lexer)]
> >>>     [(configure-runtime) `(#(honu/core/runtime configure))]
> >>>     [else
> >>>       (default-filter key default)]))
> >>>
> >>> It seems only drracket will call `get-info', though. Is there a way to 
> make 
> >> the repl call this as well, and if it doesn't can we make it?
> >>> _________________________________________________
> >>>   For list-related administrative tasks:
> >>>   http://lists.racket-lang.org/listinfo/users
> >> _________________________________________________
> >>   For list-related administrative tasks:
> >>   http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.