[racket-dev] Fwd: [racket-bug] all/12642: #lang slideshow gets error message "module: this function is not defined"

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Wed Mar 21 11:47:07 EDT 2012

How about a change to the purpose of the Languages control?

Currently, I think of the control *selecting how to determine* which 
language to use.  Example settings "whatever #lang says", "Beginning 
Student", etc.

The control could be changed to *present the determination* (by #lang or 
by some default), and only secondarily as a means to *change the 
determination* (which might mean automatically changing the #lang in the 
file).  The list of override alternatives would be something like the 
languages that this DrRacket instance knows about.  There would not be a 
"whatever #lang says" alternative, since that behavior is always the case.

For determining the language when no #lang is present (such as when 
opening a file without a #lang, or when creating a new file), the 
default could be a preference setting, with alternatives like "Guess", 
"beginning-student", "advanced-student", "racket", "racket/base"... and 
whatever other languages this DrRacket knows.  Default alternative would 
be "Guess", which I suspect will work fine for most people.

The "Guess" alternative in this preference could be some heuristics like 
Emacs and the "file" command use (later on we could make these 
heuristics extensible by packages that implement languages), and default 
to the last #lang used.  I suspect last-#lang-used would be fine, and 
any heuristics are a bonus.  (The heuristics might determine language of 
the file as distinct from #lang languages, and for each file language, 
keep track of a last-#lang-used.  So, a heuristic might recognize Scheme 
as the file's language, and then Guess would go and find what #lang the 
user last used for a Scheme file.  Again, last-#lang-used, with no 
heuristics, is fine 95%+ of the time; heuristics are mostly for 
delighting the user with DrRacket's cleverness the other 5% of the time.)

Robby's suggestion of *always* requiring #lang is tempting, and I am 
close to that, except that it would be nice to support languages that 
don't syntactically permit #lang.  For example, if we wanted to load up 
JavaScript, XML, HTML, or Java files in DrRacket.

Neil V.


Posted on the dev mailing list.