[clean-list] calling heaven from hell

Claus Reinke claus.reinke@talk21.com
Thu, 11 Jan 2001 23:16:33 -0000


> calling hell from heaven, i.e. calling c from clean is possible with
> the H to Clean 1.0 package.
> 
> Unfortunately the other way round, as I learn from the H to Clean 1.0
> documentation, is not possible: calling my nice Clean function
>  f:: String -> String 
> from C; or is there a some hidden way to do this?

Disclaimer: I'm no expert in Clean-specific foreign function call issue.

That said, and as no-one else seems to be willing to comment: even
if the situation should be as single-sided as you describe it, all might
not be lost, depending on how completely the Clean to C calls are
handled. People tend to forget that heaven's gate opens both ways:
if you can call C-functions from Clean, you pass through in both
directions. Now, you just have to pretend that "up" is "down", and
vice versa..

In brief, the hack I suggest (only if no real solution is available) is
to call the main function of your C program from the Clean program
you want to use, and to "return" to the Clean program whenever
the C program wants to have something done in the Clean world.
How workable that is depends on the complexity of your application
and on the functionality provided by the Clean to C interface..

You would also need to restructure your C program so that Clean
can "call" to the places from where C "returned" to it, if you know
what I mean. And finally, the languages in question have different
parameter-passing conventions for "call" and "return", e.g., no
multiple parameters for "return"..

> Currently my clean program is started as an executable and communicates
> via files, which is not very nice...

Agreed. As much as I would like to see this unconventional 
workaround-idea tested, I still hope that someone points 
out a real solution..

Claus