5D User Manual

REPL

REPL is the Read-Eval-Print loop.


In order to get one, install 5D.

Installation on UN*X

Download the 5d_ deb file from 5D Site and install it using:

dpkg -i 5d_*_amd64.deb

(or whatever architecture you have instead of amd64).

You might also install some libraries, especially 5d-os in order to be able to use basic OS functions (File IO etc) within the language.

You might also install LATEX, in order to get beautiful typesettings of 5D programs. Used are: latex, dvips, convert.

Installation on Windows

  1. Download setup.exe from 5D Site and install it like this:
  2. Click setup.exe

You might also install some libraries, especially 5DLibs.exe in order to be able to use basic OS functions (File IO etc) within the language.

Installation on Nokia N900

See Installation on UN*X. The architecture is armel .

Installation on Amazon Kindle

Download the update_5D_ file from 5D Site and install it like this:

  1. Connect your Kindle to the PC and copy the file onto it, into the root directory.
  2. Eject the drive and disconnect your Kindle.
  3. In the menu on the Kindle, select software update.
  4. Click OK.

After installation, run one of the following:

Operating SystemProgram to Run
UN*X5D (the GUI), T5D -i (the shell).
Windows5D (the GUI), T5D -i (the shell).

The T5D shell (in expression mode) looks like this:

5D Version 0.6.7 - Copyright (C) 2011 Danny Milosavljevic et al.
This program comes with ABSOLUTELY NO WARRANTY.
It is free software, and you are welcome to redistribute it under certain conditions. See /usr/share/doc/5d/copyright for details.
eval $ 

The T5D -i shell (in IO mode) looks like this:

5D Version 0.6.7 - Copyright (C) 2011 Danny Milosavljevic et al.
This program comes with ABSOLUTELY NO WARRANTY.
It is free software, and you are welcome to redistribute it under certain conditions. See /usr/share/doc/5d/copyright for details.
runIO $ 

If you actually want to execute IO actions in order, use the IO mode. Otherwise, you can only describe IO actions.

By convention, IO actions are functions whose name ends with an exclamation mark (!).


In order to permanently import modules, use REPL.import!.

REPL.import! "<name>"

import! will:

(In fact, import! is shorthand for a combination of define! (or let) and requireModule).

Example:

REPL.import! "Arithmetic"

In order to permanently define some variable in the environment, use define!.

REPL.define! '<name> (<body>)"

Example:

REPL.define! 'f (\x x*x)
return! (f 2) => 4

For non-permanent stuff, running T5D without -i is recommended, then you can leave off return! (permanently imported modules will be reloaded anyway).

Future Work

In the future, it is planned to remove all this strange business and instead just have the current expression include all imports (probably need better editing than readline for that, not sure).

Then, no permanent mode will be needed and no special config file which contains these permanent definitions.

IO mode will still be needed, not sure what to do about that.

Example (working right now):

let Arithmetic := requireModule "Arithmetic" in 
import [(+) (-) (*) (/)] from Arithmetic in 
5 + 42