Node:Scheme types in Java, Next:, Previous:Low-level functions, Up:Low-level functions



Scheme types in Java

All Scheme values are implemented by sub-classes of java.lang.Object.

Scheme symbols are implemented using java.lang.String. (Don't be confused by the fact the Scheme sybols are represented using Java Strings, while Scheme strings are represented by kawa.lang.Scheme. It is just that the semantics of Java strings match Scheme symbols, but do not match mutable Scheme strings.) Interned symbols are presented as interned Strings. (Note that with JDK 1.1 string literals are automatically interned.)

Scheme integers are implemented by gnu.math.IntNum. Use the make static function to create a new IntNum from an int or a long. Use the intValue or longValue methods to get the int or long value of an IntNum.

A Scheme "flonum" is implemented by gnu.math.DFloNum.

A Scheme pair is implemented by kawa.lang.Pair.

A Scheme vector is implemented by kawa.lang.Vector.

Scheme characters are implemented using kawa.lang.Char.

Scheme strings are implemented using kawa.lang.FString.

Scheme procedures are all sub-classes of kawa.lang.Procedure. Normally each function (lambda expression) in the source code is compiled to a separate sub-class of Procedure. The "action" of a Procedure is invoked by using one of the apply* methods: apply0, apply1, apply2, apply3, apply4, or applyN. Various sub-class of Procedure provide defaults for the various apply* methods. For example, a Procedure2 is used by 2-argument procedures. The Procedure2 class provides implementations of all the apply* methods except apply2, which must be provided by any class that extends Procedure2.