How to set language to htdp/bsl in REPL
Asked Answered
T

2

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?

Tafoya answered 4/9, 2017 at 23:28 Comment(3)
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.Ozmo
@Ozmo 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?Tafoya
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.Ozmo
D
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.

Dermatitis answered 27/9, 2017 at 18:7 Comment(0)
O
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).

Ozmo answered 9/9, 2017 at 19:39 Comment(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...)Dermatitis

© 2022 - 2024 — McMap. All rights reserved.