REPL is the Read-Eval-Print loop.
In order to get one, install 5D.
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.
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.
See Installation on UN*X. The architecture is armel .
Download the update_5D_ file from 5D Site and install it like this:
After installation, run one of the following:
Operating System | Program to Run |
---|---|
UN*X | 5D (the GUI), T5D -i (the shell). |
Windows | 5D (the GUI), |
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!.
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!.
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).
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