Miscellaneous

This section lists the primitives defined in STK that did not fit anywhere else.





`=̀13`(ndexfile(index-entry "eval" "tt" main )evalexpr)
syntax
`=̀13`(ndexfile(index-entry "eval" "tt" main )evalexpr environment)
syntax
Evaluates expr in the given environment. Environment may be omitted, in which case it defaults to the global environment. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(define foo (let ((a 1)) (lambda () a)))(foo) 1(eval '(set! a 2) (procedure-environment foo))(foo) 2





`=̀13`(ndexfile(index-entry "version" "tt" main )version)
procedure
returns a string identifying the current version of STK.





`=̀13`(ndexfile(index-entry "machine-type" "tt" main )machine-type)
procedure
returns a string identifying the kind of machine which is running the interpreter. The form of the result is [os-name]-[os-version]-[processor-type].





`=̀13`(ndexfile(index-entry "random" "tt" main )randomn)
procedure
returns an integer in the range 0, $\it {}n\/$ - 1 inclusive.





`=̀13`(ndexfile(index-entry "set-random-seed!" "tt" main )set-random-seed!seed)
procedure
Set the random seed to the specified seed. Seed must be an integer which fits in a C long int.





`=̀13`(ndexfile(index-entry "eval-string" "tt" main )eval-stringstring environment)
procedure
Evaluates the contents of the given string in the given environment and returns its result. If environment is omitted it defaults to the global environment. If evaluation leads to an error, the result of ndexfile(index-entry "eval-string" "tt" aux )eval-string is undefined. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(define x 1)(eval-string "(+ x 1)")   2(eval-string "x" (let ((x 2)) (the-environment))) 2





`=̀13`(ndexfile(index-entry "read-from-string" "tt" main )read-from-stringstring)
procedure
Performs a read from the given string. If string is the empty string, an end of file object is returned. If an error occurs during string reading, the result of ndexfile(index-entry "read-from-string" "tt" aux )read-from-string is undefined. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(read-from-string "123 456") 123(read-from-string "")        an eof object





`=̀13`(ndexfile(index-entry "dump" "tt" main )dumpstring)
procedure
ndexfile(index-entry "Dump" "tt" aux )Dump grabs the current continuation ndexfile(index-entry "continuation" "rm" main ) and creates an image of the current STK interpreter in the file whose name is string6. This image can be used later to restart the interpreter from the saved state. See the STK man page about the -image option for more details.

Note: Image creation cannot be done if Tk is initialized.





`=̀13`(ndexfile(index-entry "trace-var" "tt" main )trace-varsymbol thunk)
procedure
ndexfile(index-entry "Trace-var" "tt" aux )Trace-var call the given thunk when the value of the variable denoted by symbol is changed. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(define x 1)(define y 0)(trace-var 'x (lambda () (set! y 1)))(set! x 2)(cons x y)                      (2 . 1)

Note: Several traces can be associated with a single symbol. They are executed in reverse order to their definition. For instance, the execution of $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(begin   (trace-var 'z (lambda () (display "One")))  (trace-var 'z (lambda () (display "Two")))  (set! z 10))
will display the string "Two" before the string "One" on the current output port.





`=̀13`(ndexfile(index-entry "untrace-var" "tt" main )untrace-varsymbol)
procedure
Deletes all the traces associated to the variable denoted by symbol.





`=̀13`(ndexfile(index-entry "error" "tt" main )errorstring string1 obj2 … )
procedure
ndexfile(index-entry "error" "tt" aux )error prints the objs according to the specification given in string on the current error port (or in an error window if Tk is initializedndexfile(index-entry "Tk toolkit" "rm" aux )ndexfile(index-entry "toolkit" "rm" aux )). The specification string follows the ``tilde conventions'' of ndexfile(index-entry "format" "tt" aux )format(see [*]). Once the message is printed, execution returns to toplevel.





`=̀13`(ndexfile(index-entry "gc" "tt" main )gc)
procedure
Runs the garbage collector. See [*] for the signals associated to garbage collection.





`=̀13`(ndexfile(index-entry "gc-stats" "tt" main )gc-stats)
procedure
Provides some statistics about current memory usage. This procedure is primarily for debugging the STK interpreter, hence its weird printing format.





`=̀13`(ndexfile(index-entry "expand-heap" "tt" main )expand-heapn)
procedure
Expand the heap so that it will contains at least n cells. Normally, the heap automatically grows when more memory is needed. However, using only automatic heap growing is sometimes very penalizing. This is particulary true for programs which uses a lot of temporary data (which are not pointed by any a variable) and a small amount of global data. In this case, the garbage collector will be often called and the heap will not be automatically expanded (since most of the consumed heap will be reclaimed by the GC). This could be annoying epecially for program where response time is critical. Using ndexfile(index-entry "expand-heap" "tt" aux )expand-heap permits to enlarge the heap size (which is set to 20000 cells by default), to avoid those continual calls to the GC.





`=̀13`(ndexfile(index-entry "get-internal-info" "tt" main )get-internal-info)
procedure
Returns a 7-length vector which contains the following informations:

0
total cpu used in milli-seconds
1
number of cells currently in use.
2
total number of allocated cells
3
number of cells used since the last call to ndexfile(index-entry "get-internal-info" "tt" aux )get-internal-info
4
number of gc runs
5
total time used in the gc
6
a boolean indicating if Tk is initialized





`=̀13`(ndexfile(index-entry "sort" "tt" main )sortobj predicate)
procedure
Obj must be a list or a vector. ndexfile(index-entry "Sort" "tt" aux )Sort returns a copy of obj sorted according to predicate. Predicate must be a procedure which takes two arguments and returns a true value if the first argument is strictly ``before'' the second. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(sort '(1 2 -4 12 9 -1 2 3) <)                (-4 -1 1 2 2 3 9 12)(sort #("one" "two" "three" "four")       (lambda (x y) (> (string-length x) (string-length y))))                       #("three" "four" "one" "two")





`=̀13`(ndexfile(index-entry "uncode" "tt" main )uncodeform)
procedure
When STK evaluates an expression it encodes it so that further evaluations of this expression will be more efficient. Since encoded forms are generally difficult to read, ndexfile(index-entry "uncode" "tt" aux )uncode can be used to (re-)obtain the original form. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(define (foo a b)    (let ((x a) (y (+ b 1))) (cons x y)))

(procedure-body foo) (lambda (a b) (let ((x a) (y (+ b 1))) (cons x y)))(foo 1 2) (1 . 3)(procedure-body foo) (lambda (a b) (#let (x y) (#<local a @0,0)> (#<global +> #<local b @0,1)> 1)) (#<global cons> #<local x @0,0)> #<local y @0,1)>)))

(uncode (procedure-body foo)) (lambda (a b) (let ((x a) (y (+ b 1))) (cons x y)))

Note: When a macro has been directly expanded into the macro call code, it is not possible to retrieve the original macro call. Set ndexfile(index-entry "*debug*" "tt" aux )*debug* to #t to avoid macro expansion in-lining.





`=̀13`(ndexfile(index-entry "time" "tt" main )timeexpr)
macro
Evaluates the expression expr in the current environment. Prints the elapsed CPU time and the number of conses used before returning the result of this evaluation.





`=̀13`(ndexfile(index-entry "apropos" "tt" main )apropossymbol)
procedure
ndexfile(index-entry "Apropos" "tt" aux )Apropos returns a list of symbol whose print name contains the characters of symbol. Symbols are searched for in the current environment. $\Longrightarrow$
$\Longrightarrow$ unspecified error makeotherˆ`=̀13`


          gobblecr(apropos 'cadd) (caddar caddr cadddr)





`=̀13`(ndexfile(index-entry "inspect" "tt" main )inspectobj)
procedure
ndexfile(index-entry "Inspect" "tt" aux )Inspect permits to graphically inspect an object. The first call of this procedure creates a top level window containing the object to inspect and its current value. If the inspector window is already on screen, obj will be appended to the list of inspected objects. The inspector window contains menus which permit to call the viewer or detailer on each inspected object. See the on-line documentation for further details. A view of the general inspector is given in figure 1.

Note: Tk must be initialized to use ndexfile(index-entry "inspect" "tt" aux )inspect.

Figure: A view of the Inspector
\begin{figure}\centerline{\psfig{figure={Inspector.ps}}}\end{figure}





`=̀13`(ndexfile(index-entry "view" "tt" main )viewobj)
procedure
ndexfile(index-entry "View" "tt" aux )View permits to obtain a graphical representation of an STK object. The type of representation depends on the type of the viewed object. Here again, menus are provided to switch to the inspector or to the detailer. See the on-line documentation for more details. A snapshot of the viewer is given in figure 2.

Note: Tk must be initialized to use ndexfile(index-entry "view" "tt" aux )view.

Figure: A view of the Viewer
\begin{figure}\centerline{\psfig{figure={View.ps}}}\end{figure}






`=̀13`(ndexfile(index-entry "detail" "tt" main )detailobj)
procedure
ndexfile(index-entry "detail" "tt" aux )detail permits to display the fields of a composite Scheme object. The type of detailer depends on the type of the composite object detailed. Here again, menus are provided to go to the inspector or to the viewer. See the on-line documentation for more details. Figure 3 shows the detailer examining a tk-command.

Note: Tk must be initialized to use ndexfile(index-entry "detail" "tt" aux )detail.

Figure: A view of the Detailer
\begin{figure}\centerline{\psfig{figure={Detail.ps}}}\end{figure}





`=̀13`(ndexfile(index-entry "quit" "tt" main )quitretcode)
procedure
`=̀13`(ndexfile(index-entry "quit" "tt" main )quit)
procedure
`=̀13`(ndexfile(index-entry "exit" "tt" main )exitretcode)
procedure
`=̀13`(ndexfile(index-entry "exit" "tt" main )exit)
procedure
`=̀13`(ndexfile(index-entry "bye" "tt" main )byeretcode)
procedure
`=̀13`(ndexfile(index-entry "bye" "tt" main )bye)
procedure
Exits the STK interpreter with the specified integer return code. If omitted, the interpreter terminates with a return code of 0.