Anonymous user
Use another language to call a function: Difference between revisions
Use another language to call a function (view source)
Revision as of 06:30, 6 October 2016
, 7 years ago→{{header|zkl}}: text
(→{{header|Tcl}}: added zkl) |
m (→{{header|zkl}}: text) |
||
Line 1,072:
<lang c>// query.c
// export zklRoot=/home/ZKL
// clang query.c -I $zklRoot/VM -L $zklRoot/Lib -lzkl -pthread
// LD_LIBRARY_PATH=$zklRoot/Lib ./query
Line 1,089:
pVM vm;
MLIST(mlist,10);
// Bad practice: not protecting things from the garbage collector
// build the call parameters: ("query.zkl",False,False,True)
Line 1,094 ⟶ 1,096:
BoolFalse,BoolFalse,BoolTrue,ZNIL);
// Import is in the Vault, a store of useful stuff
// We want to call TheVault.Import.import("query.zkl",False,False,True)
// which will load/compile/run query.zkl
r = fcnRunith("Import","import",(Instance *)mlist,NoVM);
Line 1,115 ⟶ 1,117:
return 0;
}</lang>
Our query program
<lang zkl>// query.zkl
var query="Here am I";</lang>
Line 1,121 ⟶ 1,123:
{{out}}
<pre>
$ clang query.c -I $zklRoot/VM -L $zklRoot/Lib -lzkl -pthread
$ LD_LIBRARY_PATH=$zklRoot/Lib ./query
Query() --> "Here am I"
|