mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 20:33:55 +00:00
Estimated hours taken: 0.5 Branches: main Fix the dynamic linking examples in extras. extras/dynamic_linking/dl_test.m: extras/dynamic_linking/dl_test2.m: extras/dynamic_linking/hello.m: Conform to name changes in the dl module. Clean up the code so that it conforms to our current coding standard.
50 lines
1.4 KiB
Mathematica
50 lines
1.4 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%-----------------------------------------------------------------------------%
|
|
%
|
|
% Example module for use with dynamic linking.
|
|
% The driver program dl_test.m dynamically loads the object code
|
|
% for this module and then calls the procedures defined here,
|
|
% e.g. hello/2.
|
|
%
|
|
% This source file is hereby placed in the public domain. -fjh (the author).
|
|
%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module hello.
|
|
:- interface.
|
|
|
|
:- import_module float.
|
|
:- import_module int.
|
|
:- import_module io.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
% A very basic test: print "Hello world".
|
|
%
|
|
:- pred hello(io::di, io::uo) is det.
|
|
|
|
% Test passing floating point arguments.
|
|
%
|
|
:- func add3(float, float, float) = float.
|
|
|
|
% Test passing integer arguments.
|
|
%
|
|
:- func add3int(int, int, int) = int.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
hello(!IO) :-
|
|
io.print("Hello, world\n", !IO).
|
|
|
|
add3(X, Y, Z) = X + Y + Z.
|
|
|
|
add3int(X, Y, Z) = X + Y + Z.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
:- end_module hello.
|
|
%-----------------------------------------------------------------------------%
|