Post

Getting Started with Medley Interlisp

The environment is so weird you won't know where to start!

Medley Logo

I have long been interested in computing environments where the development tools are an integral part of the whole system. This started out ages and ages ago, when I started learning to write software in Java. When Sun released the first version of Java it was often compared to Smalltalk (in fact, IBM’s first Java IDE was written in Smalltalk). At that time the Smalltalk environments were more compelling and easier to use than Java and I was somewhat smitten.

I later discovered that the Lisp and Smalltalk environments of the 1980s were borrowing and swapping ideas and that they were very different from the “integrated development environment” (IDE) that I was using to write Java code. In these environments the developer was meant to write code that extended the system in some way. Applications you developed essentially became part of the environment and to a very real degree you built the tools that you needed to get your work done. Those tools could in turn be used by other developers and you could build on any functionality you ran across. This idea lives on in Emacs but I’m hard pressed to think of other tools that embrace pervasive extension.

Contrast this with computing today where we have so much more power at our fingertips but it’s much more difficult to put it to use (even if you are using Emacs 😉). Neither Windows or MacOS comes with development tools installed and both have spent a lot of time and energy making it difficult to customize the environment in any meaningful way, most people simply grow accustomed to whichever one they are using. For almost any task you need to install a separate application and each application (and it’s output) is deliberately silo-d off from every other. Even if you download their development tools, scaffolding up a new project is a time consuming endeavor that few have the motivation to pursue.

I can’t help but wonder if we will reach some inflection point and people will demand more flexibility out of their computing environments and the software they use. Why isn’t there a tool that let’s us manipulate our data, regardless of which application might have created it? Why is it so difficult to compose a sort of uber-document that includes text from a word processor, a couple of spreadsheets and interactive charts? With the pervasive networking environment we all live in, why so much frustration moving data from my laptop to my phone or, heaven forbid, someone else’s phone?

Taking a look at some of these old environments, like Medley, might give us some ideas of how things might be made to work more for us. Ways we can put the personal back in “personal computing”.

Getting Started with Medley Interlisp

In any case Medley Interlisp is one of these environments that you, the developer, are meant to mold to meet your needs. It comes with extensive documentation and it’s clearly designed to soak up all of your time and imagination. There is an ongoing project to get Medley running on current hardware and steady progress is being made every day, presently it’s at the point where you can run it on the major operating systems. When I started playing with it there wasn’t much in the way of tutorials, this articles tries to lay a little groundwork so that you can get started and, at the very least, get an idea of how it works.

You can run Medley in your browser or download and run Medley locally. I installed it locally but it doesn’t make much difference to this tutorial. If you do take the online route, you will need to create an account to save your data between sessions.

Once you have Medley installed you can invoke the “medley.sh” or “medley.bat” script to start the environment. A directory named “il” will be created in the root of your home directory, the state of the environment and files you create will be stored there by default.

Writing a Simple Program

Sad though it may be, it took me quite a while and plenty of Googling and YouTube watching in order to write a handful of functions and get them saved to disk! Lucky for you, reading this article is much simpler. To get you accustomed to the environment we’ll write a couple of simple functions to “greet” the person (you) and then save them to disk and load them back.

The Executive

The Medley Executive

Medley provides a window with a read-eval-print (REPL) loop that you may use to interact with the environment, it’s called the “executive”. You can type in some code and when you press the return key it’s executed by the environment and then you are prompted to type in more code.

The Medley environment supports multiple languages, in the picture above the “Exec” window is ready to accept Interlisp code; that’s the language we’re using in this article. If your “Exec” window is set for something else (i.e. Xerox Common Lisp, XCL) then you will want to create a new one.

To create a new Exec window, right-click on any empty space on your Medley desktop; a pop-up window with a list of applications you may run will appear. Slide down to the “EXEC” option and then over to the right to choose “Interlisp”. When you let go of your mouse button you will select the location and size of the Exec window by left-clicking and dragging until the window is the size you want.

New Interlisp Exec Window

If you need to move your window, right click on the window and then choose the “Move” option. Once you let go of the mouse button you can choose the new window location by left clicking wherever you want the upper-left corner of the window to be located. You can change the size of the window by left-clicking on the bottom-right corner of the window and simply dragging it around.

Move a Window

Simple Prompt Function

We need a function that will prompt people for input, we’ll then use this to ask people their name. Go ahead and type this code in at the “Exec” window.

1
2
(DEFINEQ (SIMPLE-PROMPT (prompt)
  (PROMPTFORWORD prompt NIL NIL T NIL NIL (CHARCODE (EOL)))))

Interlisp is case sensitive and most of the functions are in all caps as this was “the way” in the 1980s. To try to make the code easier to read I’ve written the variables out in lower case. Here we define a new function, SIMPLE-PROMPT, that accepts a string of text for the prompt and then passes it onto the PROMPTFORWORD function with a bunch of flags indicating that we want to collect input from the person at the console until they hit the return key.

Once you type in the code hit the return key, it will immediately be evaluated and ready for use. Go ahead and give it a try…

1
(SIMPLE-PROMPT "What is up? ")

Pretty neat!

SIMPLE-PROMPT example

Saving Your Work

Now that we have our function handy we want to save it to a file so that we can have it with us always. Interlisp has a function that will let you link functions in your environment with files on disk. Type the following at the REPL…

1
(FILES?)

The loose functions in your environment will be listed and you will be asked if you want to “say where the above go ?” which is Medley for choosing a save location; type “y” to agree. Next you will be asked where to save the SIMPLE-PROMPT function, type in “GREETING.LISP”. Medley will ask if you want to create a new file, press “y” to agree.

You might think the file is now present on disk but there’s one more step! Right now the function is linked to a file but that is all. The MAKEFILES function handles writing the functions out to the file. Type the following in the “Exec” window to save the function to disk.

1
(MAKEFILES 'GREETING.LISP)

Now the file is on disk, it should be in the “il” folder in your home directory.

Save Function to Disk

Loading Your Work

When you need to load your functions back in, the LOAD function is there for you.

1
(LOAD 'GREETING.LISP)

Once loaded the functions will be immediately available.

Reading the Documentation

Medley provides a bunch of documentation and it’s really pretty good, this is how I found the PROMPTFORWORD function. To open a new documentation window, right click on some empty Medley desktop space and choose “DINFO”. Click somewhere to anchor the new DInfo window, two windows will appear! One will have the text of the documentation and the other a dynamic table of contents.

The scrolling of the windows is a little odd, you need to hover with the mouse pointer just a little past the left-hand margin of the DInfo window and the scrollbar will appear. You can click with the left mouse button to scroll down and the right mouse button to scroll up.

DInfo with Scrollbar

The IRM window has a dynamic table of contents, you can click on any of the items and the DInfo window will display the matching documentation. I found information on PROMPTFORWORD by clicking on “User Input/Output Packages” and then clicking on PROMPTFORWORD.

Write the Greet Function

We are almost done, the only thing left is to write our GREET function. This function will use our prompt function to get the person’s name and then it will say “hello” to them.

1
2
3
(DEFINEQ (GREET ()
  (LET ((person (SIMPLE-PROMPT "What is your name? ")))
    (PRINT (CONCAT "Hello, " person "!")))))

You may use the FILES? function to link the GREET function to your “GREETING.LISP” function and then MAKEFILES to dump it out to disk.

Editing a Function

Eventually you will need to edit an existing function. Medley has an editor you may use called “SEDIT” (Structure Editor). You can edit your GREET function like so…

1
ED (GREET)

You will need to select the location and size of the editor window by left clicking somewhere and dragging to set the window’s size. A new SEdit window will appear with your function’s code, ready for editing.

Like everything else it doesn’t work exactly as you might expect. The documentation linked above should be enough to get you started.

Good luck!


This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.