[m-rev.] Re: for review: default modes for higher-order func insts
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Oct 10 17:08:40 AEST 2001
On 10-Oct-2001, David Overton <dmo at cs.mu.OZ.AU> wrote:
> +++ tests/hard_coded/ho_func_default_inst.m
> @@ -17,27 +17,44 @@
> { Map = map },
> { F1 = Map ^ det_elem(1) },
> { F2 = Map ^ det_elem(2) },
> - io__write_string(F1(1)),
> + io__write_int(F1(1)),
> io__nl,
> write_func(F2).
>
> -:- type t == (func(int) = string).
> +:- type t == (func(int) = int).
...
> :- func map = map(int, t).
>
> -map = (map__init ^ elem(1) := hello) ^ elem(2) := world.
> +map = (((map__init
> + ^ elem(1) := foo1)
> + ^ elem(2) := foo2)
> + ^ elem(3) := foo3)
> + ^ elem(4) := foo4.
...
> +:- func foo4(int) = int.
> +:- mode foo4(in(one)) = out is det.
Surely it should be an error to insert foo4 into that map?
E.g. consider the following code:
main -->
{ F4 = map ^ det_elem(4) },
io__write_int(F4(42)).
This will end up calling foo4(42), so it ought to be a mode error.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list