Call a function in a shared library: Difference between revisions
Content added Content deleted
(adding lambdatalk) |
(add RPL) |
||
Line 1,746: | Line 1,746: | ||
cols= 96 |
cols= 96 |
||
</pre> |
</pre> |
||
=={{header|RPL}}== |
|||
There is no library concept in RPL. However, in 1990, Jan Christiaan van Winkel proposed to the RPL community a way to get something close. |
|||
Assuming the programs frequently needed are stored in a specific directory named <code>MyLib</code> located at root directory, the following program, also located at the root directory, can be invoked by any program to access one of the library features. |
|||
{{works with|Halcyon Calc|4.2.7}} |
|||
{| class="wikitable" |
|||
! RPL code |
|||
! Comment |
|||
|- |
|||
| |
|||
≪ |
|||
PATH ➜ owd |
|||
≪ HOME MyLib RCL |
|||
1 owd SIZE '''FOR''' i |
|||
owd i GET EVAL '''NEXT''' |
|||
≫ EVAL |
|||
≫ ''''CALL'''' STO |
|||
| |
|||
'''CALL''' ''( 'Program_name' -- depending on call )'' |
|||
save the old directory |
|||
push the library routine on the stack |
|||
now go back to the old directory |
|||
step by step |
|||
run the library routine |
|||
|} |
|||
{{in}} |
|||
<pre> |
|||
97 'PRIM?' CALL |
|||
</pre> |
|||
{{out}} |
|||
<pre> |
|||
1: 1 |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
This script uses Fiddle from Ruby's standard library to open <code>fakeimglib.so</code> from the [[#C|C example]]. |
This script uses Fiddle from Ruby's standard library to open <code>fakeimglib.so</code> from the [[#C|C example]]. |
||
Line 1,848: | Line 1,882: | ||
end |
end |
||
exit status</syntaxhighlight> |
exit status</syntaxhighlight> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
The standard library does not provide a way to load dynamic libraries. Without using third-party libraries, we must use the FFI to call the relevant C functions directly. |
The standard library does not provide a way to load dynamic libraries. Without using third-party libraries, we must use the FFI to call the relevant C functions directly. |