[clean-list] Communicating with other programs

Marco Kesseler M.Kesseler@aia.nl
Thu, 15 Nov 2001 12:00:31 +0100


From: "Diederik van Arkel" <diederik@cs.kun.nl>
> Van: "Siegfried Gonzi" <siegfried.gonzi@kfunigraz.ac.at>
> 
> > Has anybody ever had luck communicating with other programs? Is it
> possible from within Clean to call a
 [...]
> 
> Well naturally this is possible as the ide has to do that all the time. You
> might like to tell us what exactly you
> are trying to do and on which platform. I believe I already provided an
> answer for the Windows platform
> earlier this year here on the clean-list. You might want to check the list
> archives (I believe it was a reply
> to a question by Fabien Todescato). If you have any further questions fire
> away.

Ah well. If we are talking about interfaces, I might just as well 
proceed with one of my wishes.

Two things are relatively easy to do in Clean:
- calling another executable (see the archived post from Diederik).
- calling a C routine with more or less basic types (use hToClean).

And of  course, you can also call a Clean executable from a C 
program.

But in my book, this is not the same as 'communicating with other 
programs'. For this we need at least:
- support for more complex types, and in particular support for 
strange things like ehm... 'objects' (things with methods).
- the ability to call Clean functions from another program (of which 
we may not have the sources!). What do I have to do to write a 
Clean plug-in for say Netscape/IE?
- language-level support, not a separate tool. It would be nice to 
define in an ordinary icl/dcl file something like like "import f:: Int -> 
Real from someInclude.h" (an ordinary include file, not an adapted 
one: this is A Bad Thing for standard includes). Likewise, there 
should be some "export f to someInclude.h" statement. 

The last two items should not be THAT difficult to implement. 
hToClean functionality must be integrated and some wrapper code 
must be generated around exported functions that:
- initialise the Clean runtime system in case it was not already.
- take a C calling convention and place the arguments in the right 
places for Clean.
- call the Clean function.
- return the result using the C calling convention.

Looking a bit further it could be interesting to have support for more 
dynamic forms of inter-application communication, like 
COM/OLE(Automation)/ActiveX/Whatever on windows (.Net?). Or 
support for CORBA. I mean on the language level. See also what 
the Haskell guys have done for COM ("Calling Hell from Heaven 
and Heaven from Hell").

regards,
Marco

----------------------------------------------------------------------
Aia                                     Phone: +31 24 371 02 30
PO Box 38025                            Fax:   +31 24 371 02 31
6503 AA Nijmegen                        Email: M.Kesseler@aia.nl
The Netherlands                         URL:   http://www.aia.nl
----------------------------------------------------------------------
This E-mail and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are adressed. If you have received this E-mail in error please notify
the postmaster (postmaster@aia.nl). The authenticity of this
message cannot, at this moment, be guaranteed by ourselves. For this
reason no legal rights may be granted should the contents differ to
the original sent message. The Aia log-file of sent messages is 
deemed to be the sole, true transcript of communication unless the 
contrary, other than the received message, can be proven.
----------------------------------------------------------------------