[m-users.] Foreign language interface

Volker Wysk post at volker-wysk.de
Wed Sep 14 03:52:18 AEST 2022


Am Mittwoch, dem 14.09.2022 um 03:46 +1000 schrieb Zoltan Somogyi:
> 2022-09-14 03:28 GMT+10:00 "Volker Wysk" <post at volker-wysk.de>:
> > I assume:
> > - The foreign predicate is pure, because it is an IO action.
> > - The strings in the returned list will be garbage collected.
> > - It is necessary to copy them over to Mercury land, like I did. If
> >   pointers into the process' environment were handed over to Mercury, they 
> >   would possibly get garbage collected, what can't work.
> 
> Your assumptions are correct.
> 
> Note that the library module io.environment contains several predicates
> for accessing the environment, which work when targeting Java and C#
> as well as C, and on several operating systems. (This module is new;
> it was recently carved out of io.m.)

I have looked at the io.environment module beforehand. I've written my own
foreign predicate because there's no predicate for reading the whole
environment. Only specific environment variables can be queried. 

And I wanted to learn the FFI.  :-)


Cheers,
Volker


More information about the users mailing list