Next: , Previous: C compilers, Up: Top   [Contents][Index]


13 Foreign language interface

The Mercury foreign language interfaces allows ‘pragma foreign_proc’ to specify multiple implementations (in different foreign programming languages) for a procedure.

If the compiler generates code for a procedure using a back-end for which there are multiple applicable foreign languages, it will choose the foreign language to use for each procedure according to a builtin ordering.

If the language specified in a ‘foreign_proc’ is not available for a particular back-end, it will be ignored.

If there are no suitable ‘foreign_proc’ clauses for a particular procedure but there are Mercury clauses, they will be used instead.

C

This is the default foreign language on all back-ends which compile to C. Only available on back-ends that compile to C.

C#

This is the only foreign language for back-ends which compile to C#.

Java

This is the only foreign language for back-ends which compile to Java.