Files
mercury/tests/invalid/func_errors.m
Tyson Dowd f9b942b30e Allow functions to be declared by supplying the determinism but not the
Estimated hours taken: 12

Allow functions to be declared by supplying the determinism but not the
modes (we assume the default modes).

compiler/make_hlds.m:
	Assume default modes if determinism is declared without modes
	in the :- func declaration.

compiler/prog_io.m:
	Don't give an error message for determinism without modes for
	function.

compiler/prog_io_goal.m:
	Update documentation to reflect default mode syntax.
	Assume default modes if determinism is declared without modes
	in lambda expressions.

compiler/prog_util.m:
	Mention that declaring modes for some but not all of the
	arguments of a function will be noticed in prog_io, so shouldn't
	be a concern in this code.

doc/reference_manual.texi:
	Document the new syntax.

tests/valid/Mmakefile:
tests/valid/func_default_modes.m:
	A test case for the new syntax.
2000-02-16 07:28:13 +00:00

33 lines
620 B
Mathematica

:- module func_errors.
:- interface.
:- import_module int.
% it is an error to only declare some of the modes
:- func bar(int::in, int) = int is semidet.
:- func baz(int::in, int::in) = int is semidet.
:- func quux(int, int) = (int::out) is semidet.
:- func ok(int::in, int::in) = (int::out) is semidet.
:- pred p(int, int) is semidet.
:- mode p(in, in) is semidet.
:- pred q(int::in, int) is semidet.
:- implementation.
% foo(X, Y) = X + Y :- X > 0.
% bar(X, Y) = X + Y :- X > 0.
% baz(X, Y) = X + Y :- X > 0.
% quux(X, Y) = X + Y :- X > 0.
p(X, Y) :- X > Y.
% q(X, Y) :- X > Y.
ok(X, Y) = X + Y :- X > 0.