Contents

ieval - an interactive icon expression evaluator

ieval

ieval is a program to interactively evaluate icon expressions. Input is read from the terminal until end-of-file (control-D) is entered. Each expression has its results sequence evaluated and printed (although see the !q option below). Variables may be assigned to, and they are stored in a local environment, which may be printed by entering !env. To link with library packages, use the -i command line option. Packages can’t be imported interactively. To link with individual source files, use the -l option.

An example session

$ ieval -i lang,graphics
> &version
"Object Icon Version 1234.  Mon Aug 29 11:57:11 BST 2011"
> upto('aeiou', "The quick brown fox")
3
6
7
13
18
> w := Window()
object graphics.Window#1(ptr=136611152)
> w.close()
object graphics.Window#1(ptr=0)
> ^D
$

Input of an expression over several lines can be achieved by ending a line with a backslash character. The prompt changes to >> and the next line is concatenated to the previous one.

Command line options

ieval accepts the following command-line options :-

Remaining arguments specify files which are processed before command line input commences. They should contain valid expressions (which may be compound expressions).

Useful built-in expressions

Loading programs

An existing program can conveniently be loaded with the load() procedure. The executable search path is used to locate the given program. The loaded program’s error handler is set in order to catch any runtime errors.

Symbols in the loaded program can then be accessed using gg() (which is just a shorthand for Prog.get_global), or by setting chosen symbols as variables, using sym(). For example :-

> p := load("ivib")
co-expression#75
> dir(p)
... list of the symbols in p
> sym(p, "CanvasIcon", "Custom")
CanvasIcon = class CanvasIcon
Custom = class Custom
> dir(CanvasIcon)
... details of that class

The calls to load and sym can conveniently be combined, as follows :-

> p := load("ivib", "CanvasIcon", "Custom")
CanvasIcon = class CanvasIcon
Custom = class Custom
co-expression#75

The variable names used may be different from the symbols they map to; any “.” is mapped to a “”, and an “” is appended if a clash with a symbol in the main program would hide the loaded symbol.

Please remember that oit will remove symbols from a program if it decides they aren’t referenced. Procedures, methods and entire classes can thus be discarded, and will thus not be usable from ieval. This process of culling can be averted by using the oit option -f, or from within a program by the invocable declaration.

Keyboard shortcuts

Unless ieval is started with the -s option, it keeps a history of entered expressions, and uses the following keyboard shortcuts :-

Contents