Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set language to htdp/bsl in REPL

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?

like image 255
Flux Avatar asked Sep 04 '17 23:09

Flux


2 Answers

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.

like image 113
Leif Andersen Avatar answered Nov 14 '22 02:11

Leif Andersen


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).

like image 31
soegaard Avatar answered Nov 14 '22 01:11

soegaard