[m-dev.] for review: func decls with determinism, but no modes
Tyson Dowd
trd at cs.mu.OZ.AU
Wed Feb 16 16:54:18 AEDT 2000
On 16-Feb-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 16-Feb-2000, David Overton <dmo at ender.cs.mu.oz.au> wrote:
> > On Tue, 15 Feb, 2000 at 06:46:38PM EST, Tyson Dowd wrote:
> > > Allow functions to be declared by supplying the determinism but not the
> > > modes (we assume the default modes).
> >
> > Should you mention this in the NEWS file?
>
> I think that would be a good idea.
Also I need to fix one of the tests for function errors.
By popular demand:
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.160
diff -u -r1.160 NEWS
--- NEWS 2000/01/25 04:09:36 1.160
+++ NEWS 2000/02/16 05:38:34
@@ -12,6 +12,13 @@
that appeared in the release of the day in early January 2000.
`Value =^ field' is now the syntax for DCG field selection,
rather than `Value := ^ field'.
+
+* You can now declare functions by giving a determinism but without
+ supplying the modes. The default function modes will be assumed.
+ This is particularly useful for partial functions.
+ For example:
+ GetEvens = list__filter_map(
+ (func(X) = X is semidet :- X mod 2 = 0)).
* Functions `int:^/2' and `integer:^/2' have been removed.
Use `int__xor/2' and `integer__xor/2' instead.
Index: tests/invalid/func_errors.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/func_errors.err_exp,v
retrieving revision 1.2
diff -u -r1.2 func_errors.err_exp
--- tests/invalid/func_errors.err_exp 1998/11/15 06:56:56 1.2
+++ tests/invalid/func_errors.err_exp 2000/02/16 03:33:23
@@ -1,4 +1,3 @@
-func_errors.m:009: Error: function declaration specifies a determinism but does not specify the mode: foo(int, int).
func_errors.m:010: Error: some but not all arguments have modes: bar((int :: in), int).
func_errors.m:011: Error: function arguments have modes, but function result doesn't: baz((int :: in), (int :: in)).
func_errors.m:012: Error: function result has mode, but function arguments don't: quux(int, int).
Index: tests/invalid/func_errors.m
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/func_errors.m,v
retrieving revision 1.1
diff -u -r1.1 func_errors.m
--- tests/invalid/func_errors.m 1997/08/15 15:46:30 1.1
+++ tests/invalid/func_errors.m 2000/02/16 03:34:29
@@ -3,10 +3,10 @@
:- interface.
:- import_module int.
-% it is an error to declare determinism but not modes,
-% or to only declare some of the modes
-:- func foo(int, int) = int is semidet.
+% 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.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list