Isis interpreter utilities
Isis software documentation
Isis interpreter utilities
This document explains various utilities for interpreting Isis code, including loading
libraries from files, memory buffers, and internet sites, as well as compiling Isis programs
into a byte-code representation.
Loading programs and libraries
(load filename-or-url) # interpret isis code at the given location
(load-compiled filename-or-url) # interpret compiled isis code at the given location
(add-load-path path path ...) # add a directory to search for libraries in
load interprets an Isis program or library from the given
file name or URL. load-compiled interprets compiled Isis
code (see below for information on how to compile programs and
libraries). Both return the number of expressions that were
evaulated. Otherwise an error message is printed and Null is
returned if the source could not be found or opened.
-> (load "amazon.isis")
-> (load "macaroni.isis")
-> (load "kitchen.isis")
** load: file not found: kitchen.isis
When opening disk files, load and load-compiled will
search particular directories for the file names you specify. After
searching the current working directory, the directories named in the
variable load-path-list are searched in order. You can use
add-load-path to add your own directories to the load path.
This may be useful if you have a directory full of Isis programs or
libraries that may change location, or when you need to load files
from an Isis process running in a different place in the file system.
[ "/usr/local/isis/scripts" ]
-> (add-load-path "/home/stefan/isis/scripts")
[ "/usr/local/isis/scripts" "/home/stefan/isis/scripts" ]
Evaluating to and from strings
(eval string) # Evaluate first expression in string and return its value
(uneval val val ...) # Convert values into a single string
eval is a powerful operator that interprets the first
expression in a given string and returns its value, or Null
if no expression was found. If more than one expression is in the
string, only the first expression is evaluated. Expressions are
evaluated within the scope of the top-level environment.
-> (eval "3")
-> (eval "(+ 1 2 3 4 5)")
-> (eval "(set x 42)")
uneval performs the opposite operation. It converts one or
more Isis values into a single string (like they would be printed).
Any kind of value except for procedures may be converted.
-> (uneval 42)
-> (uneval "Convert me.")
-> (uneval 89.56 [2 3 4] True 's')
"89.560000 [ 2 3 4 ] True 's'"
-> (eval (uneval 7))
-> (uneval (eval "7"))
Interpreting from various sources
(interactive) # interpret Isis code from the standard input port
(interpret-port port) # interpret Isis code at the given input port
(interpret-file filename) # interpret Isis code in the given file
(interpret-url url) # interpret Isis code at the given url
(interpret-http host portnum document) # interpret Isis code at the given http document
(interpret-string string) # interpret Isis code in the given string
(interpret-compiled-port port) # same as above, for compiled Isis code
(interpret-compiled-http host portnum document)
The interactive primitive causes Isis to begin reading
expressions directly from the standard input port (usually the
keyboard). It is most useful as a way of beginning an interactive
session with the user while interpreting an Isis program from a file
or other source.
The other interpret- routines interpret Isis programs from
various different sources. interpret-port is perhaps the
most powerful, as it interprets Isis code from any input port, which
could be connected to virtually any source (see the documentation on
input and output ports for
more information). The others interpret code from disk files, URLs,
HTTP documents, or strings. The interpret-compiled- routines
interpret compiled Isis programs. All of these routines return the
total number expressions processed, or Null if the source
could not be opened or found.
-> (interpret-file "/usr/local/isis/scripts/movie-utilities.isis")
-> (interpret-url "http://web.media.mit.edu/~stefan/secret.isis")
I like traffic lights.
Compiling programs and libraries
(compile-port inport outport) # compile from an input port to an output port
(compile-file infilename outfilename) # compile a disk file to another disk file
These routines compile Isis programs into a fairly compact
non-human-readable format. Once compiled, a program may be
interpreted using load-compiled or one of the
interpret-compiled- operators shown above. These routines
return the total number of expressions compiled, or Null if
an error occurred.
-> (compile-file "secret.isis" "secret.compiled.isis")
-> (load-compiled "secret.compiled.isis")
I like traffic lights.
Real number precision
(set-precision significant-digits) # set precision of printed real numbers
This routine sets the maximum number significant digits used when real
numbers are printed by the interpreter. The default is 10. This
routine only affects the printing of values, not their internal
-> (set-precision 3)
-> (set-precision 15)