Archie Maskill
A software development blog

Scheme REPLs and readline (or lack thereof)

Most Scheme implementations provide a command-line REPL, allowing you to interactively enter commands and play about with the language. Unfortunately, they can be incredibly frustrating to use out-of-the-box, all because Scheme distributions tend ship without readline support. As far as I can tell, this is down to licensing issues.

readline is what provides the wonderful interactivity of the command line. If you type a long command and notice an error early on in your text, you can navigate to that spot with cursor keys and edit it, rather than having to delete all your text back to that point. It also provides the command history functionality (typing up and down to navigate through commands you have issued in the past).

Trying to use the editing and history features of readline with readline support enabled, you end up with funny-looking characters being spouted into your REPL.

There are two solutions:

  1. You can recompile your favourite Scheme implementation with readline support. I have never bothered with this, and just booted up DrScheme instead.
  2. Secondly, you can install rlwrap. (You can “apt-get install rlwrap” in Debian/Ubuntu). Once installed, simply invoke “rlwrap {your-favourite-scheme}“, and you magically have readline functionality!
    I have tried this out with mzscheme (it worked fantastically, and it provides you with paren-matching too) and scheme48 (worked well, but no paren-matching).

Now I no longer need to load up the behemoth that is DrScheme when I just want to use a Scheme-based calculator. It took 3 years of dabbling in Scheme before I heard of this. I hope this post saves someone out there some Scheme-related REPL-angst.

Advertisements

No Responses to “Scheme REPLs and readline (or lack thereof)”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: