Calling External Functions
Java
To call a static function in Java:
- Specify the package, class and method, then the arguments
to the method.
- The method must be public.
- Java is picky about argument types. See below.
(:EVAL (:JAVA (com.foo.myPackage.Humor.generateJoke ?man ?animal)))
To call a non-static function in Java:
- Specify only the method name. The first argument is the object
that contains the method. The rest of the arguments are
passed to the method.
- The method must be public
- Java is picky about argument types. See below.
(:BIND ?x (:JAVA (toString 5)))
(:EVAL (:JAVA (getColor ?object)))
Argument type conversion between Algernon and Java
Internally, Algernon represents values using a set of
classes for dynamically-typed data. When converting to
Java, it picks the most appropriate class. The table below
shows the mapping of internal types to external types and
vice versa.
Java |
Algernon |
Boolean |
true=T, false=NIL |
Double |
LispFloat |
Long |
LispInteger |
String |
All other types |
LISP
Algernon contains a built-in LISP subsystem called Jatha
that contains many of the standard Common LISP functions.
It is useful for performing many common processing tasks.
(:BIND ?x (:LISP (- ?value 5)))
(:EVAL (:LISP (cons ?x ?y)))
(:TEST (:LISP (> ?x 19)))
Back to...
Algernon commands
Algernon Documentation Central
Algernon home page