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


15 Foreign language interface

The Mercury allows the code of a procedure to be specified in a target language using a pragma foreign_proc declaration. A procedure may have more than one pragma foreign_proc declarations, provided they are in different languages. A procedure that has some pragma foreign_proc declarations may also have a Mercury definition.

If the language specified in a ‘foreign_proc’ is not available for the selected backend, it will be ignored, and the implementation will use the procedure’s Mercury definition. If there isn’t one, the compiler will generate an error.

C

This is the only foreign language whose pragma foreign_procs are used when targeting C.

C#

This is the only foreign language whose pragma foreign_procs are used when targeting C#.

Java

This is the only foreign language when whose pragma foreign_procs are used targeting Java.