To allow users to get significant configurability of SWIFTVis without having to write Java components. If you are handling larger datafiles, this is not a good option because of the overhead. If your datafiles are not that large then this can give you full configurability without having to write Java code. As one might expect, there is also a hit to performance, but again that isn't noticable for small to medium sized data files. You can play with SVScheme at the command line by running edu.swri.swiftvis.scheme.SchemeConsole out of the SWIFTVis JAR file. Use (quit) to stop the console and (defined) to see a list of all of the functions that are defined in it.
SVScheme is a derivative of the Scheme programming language, which is a derivative of the LISP programming language. This page will not fully describe programming in Scheme, there are other references that do that (main Scheme page, Schemers.org). Here we give a very brief introduction and describe the main differences between SVScheme and real Scheme. Like LISP, Scheme is based on the concept of lists. Programs and the data inside of them are stored as lists. A list has parentheses surrounding a space separated sequence of elements. The syntax of Scheme is prefix so when a function is called, you use a list where the first element is the operator. For example you can add numbers with lists like (+ 3 2) or (+ 11 33 66). The length of the list of mathematical operations is variable. You can define your own functions using the lambda keyword or use an abbreviated syntax with the define keyword. For example, the following two expressions would define a factorial function. The second is simply a shorthand for the first.
(define fact (lambda (n) (if (< n 2) 1 (* n (fact (- n 1))))))
(define (fact n) (if (< n 2) 1 (* n (fact (- n 1)))))
Unlike normal Scheme which does arbitrary precision arithmetic, SVScheme does all computations in double precision floating point numbers. They are converted to ints or single precision floating point numbers when used as parameters or values in SWIFTVis. SVScheme also has a boolean type returned by comparisons, predicates, and other boolean operations. SVScheme does not currently recognize tail recursion to convert it into a looping structure. This isn't as significant for the types of things that you are likely to do in SWIFTVis as it would be in a full application where recursion is used for main loops that have no end outside of user termination. Also unlike regular Scheme, SVScheme is case sensitive, so "let" and "Let" are not the same.
SVScheme includes the following built in operations for all contexts. There are some other operations defined when you are using SVScheme inside of SWIFTVis. These are described in the SVScheme Tutorial.
#f, #t, *, +, -, /, <, <=, =, >, >=, PI, and, caaar, caadr, caar, cadar, caddr, cadr, car, cdaar, cdadr, cdar, cddar, cdddr, cddr, cdr, cond, cons, define, eq?, equ?, equals?, eval, if, lambda, length, let, letrec, list, not, null?, number?, or, pair?, quote, symbol?, xor
The let and letrec commands are both basically letrec. There is no let*. If you feel you have a good reason to have let*, give us feedback and we might be able to implement it. Now operations are being added over time as well though we will try to keep this page updated on those. Also, regular scheme does not allow you to define to a name more than once. SVScheme removes this restrictions, though the behavior should still be avoided. In particular, it can cause odd behaviors when the thing you are redefining is a recursive function. This is because of the way SVScheme aggresively binds names to functions to enhance performance.
SVScheme does support curried functions and higher order functions so if you have any experience with Scheme programming, you should find that you are able to do most of your normal tricks in SVScheme. As always, if you find that there is something you want that isn't supported, let us know.