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.
This is the default foreign language on all back-ends which compile to C. Only available on back-ends that compile to C.
This is the only foreign language for back-ends which compile to C#.
This is the only foreign language for back-ends which compile to Java.