(I'm trying to code-generate scheme code.)
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
* If you're talking about generating files, then you can just use
"#lang mzscheme" at the top to get the (very) old legacy language.
* If you're talking about running racket, then you can use a flag to
set the initial language: "racket -I mzscheme".
* And if you're talking about editing in DrRacket, then the language
dialog has an "Automatic #lang line" that determines the line that
gets inserted into new buffers.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
> * And if you're talking about editing in DrRacket, then the language
> dialog has an "Automatic #lang line" that determines the line that
> gets inserted into new buffers.
...which you will see if you press the 'Show Details' button in the dialogue (the details appear not to be shown by default, at least on OS X).
Norman
--
Norman Gray : http://nxg.me.uk
(Yes, sorry for the omission.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
(And you know that using `load' (which is what "-f" does) is almost
always a bad idea, right?)
> But it's counterintuitive that this doesn't work:
>
> $ racket -f main.scm -l mzscheme
> main.scm:1:10: #%app: missing procedure expression; probably
> originally (), which is an illegal empty application in: (#%app)
>
> What's the right mental model for this? Is the -l causing future files
> on the commandline to be in the requested language?
The "-f" flag specifies a file to `load'; loading a file is basically
reading its contents and `eval'uating it; by default, racket starts
with an *empty* namespace, it doesn't even have function application,
which is the complaint you see.
By using `-l mzscheme', you're requiring the `mzscheme' module into
this empty namespace, and after that loading the file works fine since
all that syntax is defined. The order of the flags is meaningful,
which is why the `-l mzscheme' must be first.
> Are there online docs on the commandline flags online? racket --help
> says this about -l
>
> -l <path>, --lib <path> : Like -e '(require (lib "<path>"))'
>
> Is this right?
Yes. (And "Like" is there for a reason -- it's not really evaluating a
`require' form, since the initial namespace doesn't have that too...)
> >> Is there a way to switch the default language to mzscheme ...
> >> without getting into a module environment?
> >
> > * If you're talking about generating files, then you can just use
> > "#lang mzscheme" at the top to get the (very) old legacy
> > language.
> >
> > * And if you're talking about editing in DrRacket, then the
> > language dialog has an "Automatic #lang line" that determines
> > the line that gets inserted into new buffers.
>
> #lang also turns each file into a module,
(Yes, and as a result it gets you in a saner world.)
> and I have to make sure I require files in the right order. With
> generated code this is often non-trivial.
If you make the generated files require each other properly, then you
don't need to require more than one file. In most code generation
scenarios I have encountered, this is actually much easier to do than
to keep an ordered list of code to evaluate.
'$ racket -l mzscheme -f main.scm' turns out to be just what I wanted. Thanks!
But it's counterintuitive that this doesn't work:
$ racket -f main.scm -l mzscheme
main.scm:1:10: #%app: missing procedure expression; probably
originally (), which is an illegal empty application in: (#%app)
What's the right mental model for this? Is the -l causing future files
on the commandline to be in the requested language?
Are there online docs on the commandline flags online? racket --help
says this about -l
-l <path>, --lib <path> : Like -e '(require (lib "<path>"))'
Is this right?
>> Is there a way to switch the default language to mzscheme ...
>> without getting into a module environment?
>
> * If you're talking about generating files, then you can just use
> "#lang mzscheme" at the top to get the (very) old legacy language.
>
> * And if you're talking about editing in DrRacket, then the language
> dialog has an "Automatic #lang line" that determines the line that
> gets inserted into new buffers.
#lang also turns each file into a module, and I have to make sure I
require files in the right order. With generated code this is often
non-trivial.
Kartik
http://akkartik.name
Unfortunately it's "doubly hidden" in the UI:
1. The first thing I tried was Preferences. Never would have guessed
to find this under "Choose Language".
2. Even if you somehow knew to look under Choose Language, the options
are hidden by default. The "Show Details" button doesn't have any
"expand dialog" affordance like being labeled "Show Details >>". Plus
you might not even click that, because options like command-line args
or compiling with debugging info don't obviously feel (to a new user)
like details of choosing a language.
IMO the solution options are, in decreasing order of preference:
1. Move most of these options to a new tab in Preferences. (best)
2. Move most of these options to a new command/dialog "Racket |
Execution Options" (and maybe fold "Limit Memory" into that, too?).
3. Just make "Choose Language" an always-expanded dialog.
4. Just change "Show Details" button to "Show Details >>". (least best, IMHO)
I realize this probably sounds nit-picky. But, some usability issues
are impossible for someone to see when they've lost their virginity
and already know too much about how something is supposed to work. I
think this is a good example, so I wanted to point it out to all you
non-virgins. :)