[m-dev.] export declarations
Peter Schachte
pets at students.cs.mu.oz.au
Fri Nov 21 15:45:41 AEDT 1997
On Fri, 21 Nov 1997, Fergus Henderson wrote:
> Peter Schachte, you wrote:
> > I think the pragma should really be
> >
> > :- pragma c_export(Pred(Mode1, Mode2, ...), "C_Name_1").
> >
> > and similarly for functions. Alternatively, it could be something like:
> >
> > :- pragma export(Pred(Mode1, Mode2, ...), c("C_Name_1")).
>
> I was thinking of an extra argument, i.e.
>
> :- pragma export(Pred(Mode1, Mode2, ...), 'C', "C_Name_1").
> :- pragma export(Pred(Mode1, Mode2, ...), 'Prolog', "Prolog_Name_1").
> :- pragma export(Pred(Mode1, Mode2, ...), 'Ada', "Ada_Name_1").
> :- pragma export(Pred(Mode1, Mode2, ...), 'Java', "Java_Name_1").
The trouble with that is it doesn't give you the opportunity to specify
different information for different languages. For example, for an
assembler interface you might want to specify a list of register names to
pass parameters in, or who knows what information you might want for C++ to
be able to write a method directly in Mercury. You might also like the
option of having the name just default to the predicate name, so you could
allow all of:
:- pragma export(foo(...), c("Foo")).
:- pragma export(bar(...), c).
:- pragma export(baz(...), asm([r1,r3,r2,r2])).
Each implementation would decide which sorts of export terms to support.
> Another feature which may be useful: the Ada `pragma export' (which
> was a major source of inspiration for the Mercury `pragma export')
> allows you to specify the assembler-level link name instead of the
> external language name.
This could be handled with something like
:- pragma export(foo(...), c_with_asm_name("@foo")).
or maybe
:- pragma export(foo(...), c("@foo",[asm_name])).
(the second argument being a list of options), or possibly
:- pragma export(foo(...), c(asm_name("@foo"))).
(the idea being that the name can be wrapped with asm_name/1 for any
language; nice orthogonality, but not as pretty).
Either of the approaches I initially suggested gives you a flexible
framework into which you can put all kinds of things later, which simply
adding a language name argument doesn't.
-Peter Schachte | Politicians are the same all over. They
pets at cs.mu.OZ.AU | promise to build a bridge even where there is
http://www.cs.mu.oz.au/~pets/ | no river. -- Nikita Krushchev
PGP key available on request |
More information about the developers
mailing list