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

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Apr 5 13:11:20 EDT 2012

A few minutes ago, Robby Findler wrote:
> I'm not sure I'm quite getting this. Is the idea that, if there is a
> #lang line present, DrRacket would always use that language. If there
> is no #lang line present, then DrRacket would use some other language,
> based on what was recently chosen in the language dialog?

I think that this is what Nick suggested in this thread, and Neil is
suggesting something more elaborate.

Something along these lines sounds like a good idea to me.  There's
enough random pieces of code around that students might try and get
this very bad error message.

Maybe a milder version that instead of changing the language (which
can be confusing for the same students....) pops up some dialog with a
nice message, and suggeting to switch the language to the "use the
language declared in the source".  It can have an "ok" button to
switch the language for you, and with an "always do this" checkbox you
get the above functionality when requested.  (And that would be very
convenient for many people who teach & hack, making switches easier.)

BTW₁, sounds like Neil is suggesting something similar when there is
no #lang too, going back to some language that you choose (or guess).

BTW₂, how about renaming the "use the language declared in the source"
or "Determine language from source" language as the "#lang" language?
IMO it would look better as a header in the language dialog and on the
status bar language indicator.  The long name is a description, not a
name, so it fits better the explanation part in the dialog.


> On Wed, Mar 21, 2012 at 10:47 AM, Neil Van Dyke <neil at neilvandyke.org> wrote:
> > 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.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.