[m-dev.] foreign type syntax, the pain begins.

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 1 21:54:00 AEDT 2001


On 01-Nov-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> So we are looking for something like:
> 
> :- pragma foreign_type(xmldoc, csharp, "System.Xml.XmlDocument").

That is my favoured option.

Either that or possibly with the order of the first two arguments switched,
to be consistent with the ordering for `pragma foreign_proc'.

...
> Now the first thing to do is consider that the scheme doesn't actually
> work [...]
> The problem is that you need to specify the assembly that each type
> belongs to, and pass that as a command line option to the C# compiler.

Actually you specify which assemblies this source file references,
and then the C# compiler reads in the meta-data for those assemblies
and uses that to figure out which assembly each type is in.

> Unless you would like to have the mmc
> commandline options also accept C# options

That seems to me like the logical approach...

We already have `--cflags' and `--c-include-directory',
and `--java-flags' and `--java-classpath', so why not
`--csharp-flags' and `--csharp-assembly'?

A drawback of this approach is that it means if/when we get to the point
of wanting to parse the syntax, so that you can use a single declaration
rather than one for each language that you want to interface with,
then we'd need to do the same work as the C# compiler.
That is, we'd need to read in the meta-data for the referenced
assemblies use that to figure out which assembly each type was in.
That could be a lot of work and so we probably don't want to do that.
So I guess the "master" syntax for the .NET back-end would have to
be IL rather than C#.

> For MC++ [...]
> Or we could force the user to include an appropriate foreign_decl:

That's my preference.

:- pragma foreign_decl('MC++', "#using <System.XML.dll>").
:- pragma foreign_type(xmldoc, 'MC++', "System::Xml::XmlDocument").

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  | "... it seems to me that 15 years of
The University of Melbourne         | email is plenty for one lifetime."
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- Prof. Donald E. Knuth
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list