All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Jaja.Procedure

java.lang.Object
   |
   +----Jaja.Jaja
           |
           +----Jaja.Value
                   |
                   +----Jaja.Procedure

public abstract class Procedure
extends Value
This is the class defining the behavior of all Scheme predefined procedures. These behaviors do not correspond to Scheme values (see PredefinedValues for that) answering true to procedure? predicate, they rather are the Java methods that implement the Jaja primitives. You may use directly those behaviors that have a fixed arity by saying Procedure.cons(aValue, anotherValue) or simply as car(aValue) if inheriting from the Procedure class. If the arity is variant, these are n-ary functions, then write list(anArrayOfValues) instead.

No explicit error checking is done that is, we leave to Java to take care of the validity of cast or message sending. Therefore we do not need a special Exception class nor we have to explicit that these procedures may throw RuntimeExceptions.

Most of the implementation lies in the functions here and not in the classes that define the associated data (ie car is there and not in Pair.java). This is to avoid indirections (as well as name clashes: the static car method cannot be defined in Pair that already contains a car field). Since Scheme is not statically typed, all these functions take Values and return Values. Arguments are appropriately cast in their definition (these casts are checked by Java).

The invocation mechanism is pretty complex. The shape of a call to a procedure p depends on the number of arguments. Only invocations up to ten arguments are considered. Invocations with strictly more than 3 arguments pass through an array of arguments otherwise the procedure is invoked with that number of arguments.

Arity checking is done by Java. All methods that follow are default methods and must be refined according to the type of the procedure (@see Subr2 for instance that refines the invoke method for two arguments).


Constructor Index

 o Procedure()

Method Index

 o apply(Value[])
apply can only manages up to ten arguments.
 o booleanp(Value)
 o callep(Value)
callep is a call/cc reduced to its dynamic extent.
 o car(Value)
 o cdr(Value)
 o char_to_integer(Value)
 o charp(Value)
 o close_port(Value)
 o cons(Value, Value)
 o current_input_port()
 o current_output_port()
 o detach(Value[])
Parallelism.
 o display(Value[])
 o divide(Value, Value)
 o eofp(Value)
 o eqnp(Value, Value)
 o eqp(Value, Value)
 o equalp(Value, Value)
 o exit(Value)
 o fixnump(Value)
 o floatnump(Value)
 o gep(Value, Value)
 o gtp(Value, Value)
 o integer_to_char(Value)
 o invoke()
 o invoke(Value)
 o invoke(Value, Value)
 o invoke(Value, Value, Value)
 o invoke(Value, Value, Value, Value)
 o invoke(Value, Value, Value, Value, Value)
 o invoke(Value, Value, Value, Value, Value, Value)
 o invoke(Value, Value, Value, Value, Value, Value, Value)
 o invoke(Value, Value, Value, Value, Value, Value, Value, Value)
 o invoke(Value, Value, Value, Value, Value, Value, Value, Value, Value)
 o invoke(Value, Value, Value, Value, Value, Value, Value, Value, Value, Value)
 o invoke(Value[])
RESTRICTION: The Scheme to Java compiler does not support functions with more than 10 arguments (nor the implementation of apply).
 o lep(Value, Value)
 o list(Value[])
 o ltp(Value, Value)
 o make_string(Value[])
 o make_vector(Value[])
 o minus(Value, Value)
 o modulo(Value, Value)
 o newline(Value[])
 o nullp(Value)
 o numberp(Value)
 o oblist()
 o open_input_file(Value)
 o open_output_file(Value)
 o pairp(Value)
 o plus(Value[])
 o procedurep(Value)
 o quotient(Value, Value)
 o read(Value[])
 o remainder(Value, Value)
 o set_car(Value, Value)
 o set_cdr(Value, Value)
 o string(Value[])
 o string_length(Value)
 o string_ref(Value, Value)
 o string_set(Value, Value, Value)
 o string_to_symbol(Value)
 o stringp(Value)
 o symbol_to_string(Value)
 o symbolp(Value)
 o times(Value[])
 o vector(Value[])
 o vector_length(Value)
 o vector_ref(Value, Value)
 o vector_set(Value, Value, Value)
 o vectorp(Value)
 o write(Value[])

Constructors

 o Procedure
 public Procedure()

Methods

 o invoke
 public Value invoke()
 o invoke
 public Value invoke(Value a)
 o invoke
 public Value invoke(Value a,
                     Value b)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c,
                     Value d)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c,
                     Value d,
                     Value e)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c,
                     Value d,
                     Value e,
                     Value f)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c,
                     Value d,
                     Value e,
                     Value f,
                     Value g)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c,
                     Value d,
                     Value e,
                     Value f,
                     Value g,
                     Value h)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c,
                     Value d,
                     Value e,
                     Value f,
                     Value g,
                     Value h,
                     Value i)
 o invoke
 public Value invoke(Value a,
                     Value b,
                     Value c,
                     Value d,
                     Value e,
                     Value f,
                     Value g,
                     Value h,
                     Value i,
                     Value j)
 o invoke
 public Value invoke(Value args[])
RESTRICTION: The Scheme to Java compiler does not support functions with more than 10 arguments (nor the implementation of apply).

 o car
 public static Value car(Value a)
 o cdr
 public static Value cdr(Value a)
 o cons
 public static Value cons(Value a,
                          Value d)
 o set_car
 public static Value set_car(Value p,
                             Value a)
 o set_cdr
 public static Value set_cdr(Value p,
                             Value a)
 o list
 public static Value list(Value args[])
 o eqp
 public static Value eqp(Value a,
                         Value b)
 o equalp
 public static Value equalp(Value a,
                            Value b)
 o pairp
 public static Value pairp(Value a)
 o nullp
 public static Value nullp(Value a)
 o symbolp
 public static Value symbolp(Value a)
 o stringp
 public static Value stringp(Value a)
 o numberp
 public static Value numberp(Value a)
 o fixnump
 public static Value fixnump(Value a)
 o floatnump
 public static Value floatnump(Value a)
 o procedurep
 public static Value procedurep(Value a)
 o booleanp
 public static Value booleanp(Value a)
 o charp
 public static Value charp(Value a)
 o eofp
 public static Value eofp(Value a)
 o symbol_to_string
 public static Value symbol_to_string(Value a)
 o plus
 public static Value plus(Value args[])
 o minus
 public static Value minus(Value a,
                           Value b)
 o times
 public static Value times(Value args[])
 o divide
 public static Value divide(Value a,
                            Value b)
 o quotient
 public static Value quotient(Value a,
                              Value b)
 o remainder
 public static Value remainder(Value a,
                               Value b)
 o modulo
 public static Value modulo(Value a,
                            Value b)
 o lep
 public static Value lep(Value a,
                         Value b)
 o gep
 public static Value gep(Value a,
                         Value b)
 o eqnp
 public static Value eqnp(Value a,
                          Value b)
 o ltp
 public static Value ltp(Value a,
                         Value b)
 o gtp
 public static Value gtp(Value a,
                         Value b)
 o vectorp
 public static Value vectorp(Value arg1)
 o make_vector
 public static Value make_vector(Value args[])
 o vector_ref
 public static Value vector_ref(Value v,
                                Value i)
 o vector_set
 public static Value vector_set(Value v,
                                Value i,
                                Value o)
 o vector_length
 public static Value vector_length(Value v)
 o vector
 public static Value vector(Value args[])
 o integer_to_char
 public static Value integer_to_char(Value n)
 o char_to_integer
 public static Value char_to_integer(Value c)
 o string_length
 public static Value string_length(Value s)
 o string_ref
 public static Value string_ref(Value s,
                                Value i)
 o string_set
 public static Value string_set(Value s,
                                Value i,
                                Value c)
 o make_string
 public static Value make_string(Value args[])
 o string
 public static Value string(Value args[])
 o string_to_symbol
 public static Value string_to_symbol(Value arg1)
 o read
 public static Value read(Value args[])
 o display
 public static Value display(Value args[])
 o write
 public static Value write(Value args[])
 o newline
 public static Value newline(Value args[])
 o current_input_port
 public static Value current_input_port()
 o current_output_port
 public static Value current_output_port()
 o open_input_file
 public static Value open_input_file(Value s)
 o open_output_file
 public static Value open_output_file(Value s)
 o close_port
 public static Value close_port(Value p)
 o callep
 public static Value callep(Value arg)
callep is a call/cc reduced to its dynamic extent.

 o apply
 public static Value apply(Value args[])
apply can only manages up to ten arguments.

 o exit
 public static Value exit(Value arg1)
 o oblist
 public static Value oblist()
 o detach
 public static Value detach(Value args[])
Parallelism. (detach! function arguments...) spawns a new thread in background and returns immediately. The continuation of that invokation throws away the obtained value and commits suicide. It is not possible to escape that continuation. Nevertheless, this invokation shares the dynamic environment of the invoker.


All Packages  Class Hierarchy  This Package  Previous  Next  Index