7

I have the following htdp/bsl program saved as example.rkt:

#lang htdp/bsl
(+ 1 1)

When the above is run using racket example.rkt, the output is as expected (i.e. 2).

However, when I try to start an REPL with htdp/bsl as the language (racket -I htdp/bsl), the following error appears:

Welcome to Racket v6.3.
 default-load-handler: cannot open module file
  module path: (lib "htdp/bsl")
  path: /usr/share/racket/pkgs/htdp-lib/htdp/bsl.rkt
  system error: No such file or directory; errno=2
  context...:

This error does not appear when the language selected is typed/racket, for example.

Why does the error happen with htdp/bsl, and how do I correctly start an REPL with htdp/bsl as the language?

soegaard
  • 30,661
  • 4
  • 57
  • 106
Flux
  • 9,805
  • 5
  • 46
  • 92
  • 1
    The short answer is that `htdp/bsl` and the teaching languages in general wasn't designed to be used that way. They are designed to be used in DrRacket. – soegaard Sep 09 '17 at 09:40
  • @soegaard Is it appropriate to write BSL programs in a plain text editor and use `#lang htdp/bsl`? Or is BSL designed to be used only in DrRacket? – Flux Sep 09 '17 at 18:10
  • Depends on the type of programs you want to write. Error reporting is *much* better in DrRacket. My recommendation is to use DrRacket while learning Racket - and then switch to your preferred editor after a while. – soegaard Sep 09 '17 at 19:41

2 Answers2

6

As @soegaard said, the htdp languages really work best in DrRacket, which I highly recommend in this case. However, if you really do want a REPL outside of DrRacket (say if you are grading homework and want to make a shell script for it), then you can actually use ,enter to get a BSL repl. Say you have a BSL file called homework1.rkt, which says:

#lang htdp/bsl
"I'm a rebel"

Then what you can do is open up Racket in the files directory and enter the module. In this case you'll get something like:

$ racket
> ,enter "homework1.bsl"
"I'm a rebel"
homework1.bsl>

From here you are in a BSL repl that is very similar to the one in DrRacket.

Leif Andersen
  • 21,580
  • 20
  • 67
  • 100
4

Use

racket -I htpd/bsl/lang example.rkt

to start your program (tested with Racket version 6.3.0.1).

Also, consider updating to the current version of Racket (version 6.10).

soegaard
  • 30,661
  • 4
  • 57
  • 106
  • 1
    Interesting, so when I try `racket -I htdp/bsl/reader`, it tells me that it can't find (submod (lib "htdp/bsl/reader") configure-runtime)`, but that submodule clearly exists (and can be required...) – Leif Andersen Sep 27 '17 at 17:58