V:4.1.3/Karajan:Kernel Library
From Java CoG Kit
The Karajan kernel contains a minimum set of elements that are required in order to get the rest of the system running. All kernel elements are automatically available in any program.
Kernel Elements
kernel:project(stdout)
karajan
The root element of a Karajan program. Accepts arguments on the stdout channel and prints them immediately on the console.
kernel:import(file, ...)
include
Executes the file specified by the file argument. All arguments received on the default channel are considered to be element definitions (created with export), which import binds to the parent environment, such that after import completes execution, the definitions will be available for use.
foo(
import("file.k")
) //scope of foo() ends
Import uses the library search path specified in etc/karajan.properties, which defaults to searching the current directory first, then the Java class path. If no file with the given name is found in the library search path, import will fail.
kernel:export(name, value)
Returns the pair (name, value). The value argument should be a lambda, which can be bound by import.
export(foo,element([x],
kernel:define(name, value)
Binds a lambda, specified by the value argument to the given name.
kernel:namespace(prefix)
Allows the specification of a namespace prefix. Any elements defined in the scope of namespace will automatically have the prefix indicated by the prefix argument, unless another namespace is nested.
kernel:elementdef(type, classname)
Used by the current implementation to map element names to Java implementation classes.
kernel:named(value, *name)
Used internally by the named argument form, but can be used by the user equally well. The following are equivalent:
false())false())
However, the fact that the *name argument is optional makes it impossible to completely avoid the named form.
If the {{oarg|name} argument is not present, it simply returns the value of the value argument on the default channel.
kernel:number(value)
Can be used with the XML syntax to represent a number. There is no distinction between integral numbers and floating point numbers in Karajan.
kernel:string(value)
Can be used with the XML syntax to represent a string value.
kernel:variable(name)
Used to represent the value of a variable.
Example:
<setname="n" value="5"/> <list> <number>10</number> <string>10</string> <variable>n</variable> </list>
will return the list [10, “10”, 5].
kernel:quotedlist(...)
Used internally to represent a quoted list. The following two lines of code will produce the same result:
[a, b, c] quotedlist(a, b, c)
kernel:cache()
Caches the evaluation of the arguments. Upon subsequent executions of cache, the arguments will not be re-evaluated. Instead, the cached values will be returned. Cache does not make any checks for the invariance of the evaluation of the arguments.
