Previous: , Up: Interfacing with Erlang   [Contents] Using pragma foreign_code for Erlang

pragma foreign_code’ can be used to define additional Erlang functions which can then be referenced by ‘pragma foreign_proc’ declarations for Erlang from that module. By adding ‘-export’ directives inside ‘pragma foreign_decl’ declarations, those functions can additionally be called from outside the defining module.

For example:

:- pragma foreign_code("Erlang", "
	foo() -> io:put_chars(""Foo."").

:- impure pred say_foo is det.
:- pragma foreign_proc("Erlang", say_foo,
	[will_not_call_mercury], "foo()").