Call a foreign-language function: Difference between revisions
Add Standard ML version using PolyML
(Add Ecstasy explanation) |
(Add Standard ML version using PolyML) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 681:
=={{header|Ecstasy}}==
Ecstasy was designed around software containers and a strong security model. As such, Ecstasy does not have
=={{header|Factor}}==
Line 2,668:
Transcript showCR:( CallDemo strdup:'Hello' )</syntaxhighlight>
=={{header|Standard ML}}==
{{works with|Poly/ML}}
<syntaxhighlight lang="sml">local
val libc = Foreign.loadLibrary "libc.so.6"
val sym = Foreign.getSymbol libc "strdup"
in
val strdup = Foreign.buildCall1(sym, (Foreign.cString), Foreign.cString)
end</syntaxhighlight>
{{out}}
<pre>
> strdup "test string";
val it = "test string": string
>
</pre>
=={{header|Stata}}==
Here are examples showing how to build and call from Stata a plugin written in C or Java. See also the entries 29 to 32 in the ''[https://blog.stata.com/2016/01/15/programming-an-estimation-command-in-stata-a-map-to-posted-entries/ Programming an estimation command in Stata]'' series by David M. Drukker, on [https://blog.stata.com/ Stata Blog].
Line 2,839 ⟶ 2,855:
Although RC task solutions are usually written for execution by Wren CLI, the language's main purpose is for embedding and the embedding API is written in C. It is therefore a relative easy matter to call a C function from Wren after first embedding the latter in a suitable C program.
<syntaxhighlight lang="
class C {
Line 2,917 ⟶ 2,933:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 2,939 ⟶ 2,955:
Hello World!
</pre>
=={{header|X86-64 Assembly}}==
===UASM 2.52===
|