//[[Documentation]]

LMNtal Java allows inline code written in Java, and SLIM allows LMNtal programs to call C functions.
SLIM allows LMNtal programs to call C functions.

*Foreign-Language Interface in Java

**Syntax
*Foreign-Language Interface in SLIM

 inline_define atom
    [:/*inline_define*/ inline_define_code_in_Java :]
 inline atom
    [:/*inline*/ inline_code_in_Java :](X1,...,Xn)
SLIM allows LMNtal programs to call functions written in C.  An LMNtal atom

**Specification
>'$callback'('''function_name''', '''arg1''', '''arg2''', ...)

The execution of inline code takes place
immediately after the rewriting task of the rule
that creates the inline atom is finished.
calls the C function '''function_name''' with the specified arguments.  Examples of callbacks can be found in the library programs located in the $LMNTAL_HOME/lib directory, and the corresponding C functions can be found in the $LMNTAL_HOME/src/ext directory.

Defined variables:
 me .... the inline atom itself
 mem ... me.getMem() 

**Examples

 [:/*inline_define*/class Foo { static int counter = 0; } :].

 [:/*inline*/System.out.println(me.nthAtom(0).getName());
             me.remove();
             me.nthAtom(0).remove();:]("LMNtal\n")
 % ==> prints LMNtal

 hello(X) :- [:/*inline*/
               Atom a = mem.newAtom(new Functor("ok",1));
               me.remove();
               mem.relink(a,0,me,0);:](X).
 hello(there).
 % ==> ok(there)

*Foreign-Language Interface in SLIM

SLIM allows LMNtal programs to call functions written in C.  The LMNtal atom
'$callback'('function_name', arg1, arg2, ...) calls the C function 'function_name' with the specified arguments.  Examples of callbacks can be found in the library programs located in the lib directory and the corresponding C functions can be found in the src/ext directory.


Front page List of pages Search Recent changes Backup   Help   RSS of recent changes