Kawa, the Java-based Scheme system

Node:Standard Types, Next:Declaring Types of Variables, Previous:Types, Up:Types

### Standard Types

These types are bound to identifiers having the form `<TYPENAME>`. (This syntax and most of the names are as in RScheme.)

To find which Java classes these types map into, look in `kawa/standard/Scheme.java`.

Note that the value of these variables are instances of `gnu.bytecode.Type`, not (as you might at first expect) `java.lang.Class`.

<object> | Variable

An arbitrary Scheme value - and hence an arbitrary Java object.

<number> | Variable

The type of Scheme numbers.

<quantity> | Variable

The type of quantities optionally with units. This is a sub-type of `<number>`.

<complex> | Variable

The type of complex numbers. This is a sub-type of `<quantity>`.

<real> | Variable

The type of real numbers. This is a sub-type of `<complex>`.

<rational> | Variable

The type of complex numbers. This is a sub-type of `<real>`.

<integer> | Variable

The type of Scheme integers. This is a sub-type of `<rational>`.

<symbol> | Variable

The type of Scheme symbols.

<keyword> | Variable

The type of keyword values. See Keywords.

<list> | Variable

The type of Scheme lists (pure and impure, including the empty list).

<pair> | Variable

The type of Scheme pairs. This is a sub-type of `<list>`.

<string> | Variable

The type of (mutable) Scheme strings. This is not the same as (non-mutable) Java strings (which happen to be the same as `<symbol>`).

<character> | Variable

The type of Scheme character values. This is a sub-type of `<object>`, in contrast to type `<char>`, which is the primitive Java `char` type.

<vector> | Variable

The type of Scheme vectors.

<procedure> | Variable

The type of Scheme procedures.

<input-port> | Variable

The type of Scheme input ports.

<output-port> | Variable

The type of Scheme output ports.

<String> | Variable

This type name is a special case. It specifies the class `<java.lang.String>` (just as `<symbol>` does). However, coercing a value to `<String>` is done by invoking the `toString` method on the value to be coerced. Thus it "works" for all objects. It also works for `#!null`. When Scheme code invokes a Java methods any parameter whose type is `java.lang.String` is converted as if it was decalred as a `<String>`.

More will be added later.

A type specifier can also be one of the primitive Java types. The numeric types `<long>`, `<int>`, `<short>`, `<byte>`, `<float>`, and `<double>` are converted from the corresponding Scheme number classes. Similarly, `<char>` can be converted to and from Scheme characters. The type `boolean` matches any object, and the result is `false` if and only if the actual argument is `#f`. The return type `<void>` indicates that no value is returned.

A type specifier can also be a fully-qualified Java class name (for example `<java.lang.StringBuffer>`). In that case, the actual argument is cast at run time to the named class. Also, `<java.lang.StringBuffer[]>` represents an array of references to `java.lang.StringBuffer` objects.