[m-rev.] for review: impurity & higher-order

Simon Taylor stayl at cs.mu.OZ.AU
Sat Jan 25 13:11:44 AEDT 2003


On 25-Jan-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 24
> Branches: main
> 
> Support impurity declarations for higher-order code.
> 
> In particular, allow `impure' and `semipure' annotations on
> higher-order types, higher-order calls, and lambda expresions.

> Index: compiler/modecheck_call.m
> ===================================================================
> @@ -102,7 +102,7 @@
>  			GroundInstInfo = none,
>  			mode_info_get_var_types(ModeInfo0, VarTypes),
>  			map__lookup(VarTypes, PredVar, Type),
> -			type_is_higher_order(Type, function, _, ArgTypes),
> +			type_is_higher_order(Type, _Purity, function, _, ArgTypes),

Fix line wrapping.

> Index: compiler/modecheck_unify.m
> ===================================================================
> --- compiler/modecheck_unify.m	22 Jul 2002 06:29:42 -0000	1.52
> +++ compiler/modecheck_unify.m	22 Jan 2003 08:04:23 -0000
> @@ -133,7 +133,7 @@
>  	%
>  	(
>  		% check if variable has a higher-order type
> -		type_is_higher_order(TypeOfX, _, EvalMethod, PredArgTypes),
> +		type_is_higher_order(TypeOfX, Purity, _, EvalMethod, PredArgTypes),

And here.

> Index: compiler/purity.m
> ===================================================================
> --- compiler/purity.m   22 Jul 2002 06:29:46 -0000      1.48
> +++ compiler/purity.m   24 Jan 2003 06:56:37 -0000
> @@ -107,6 +107,8 @@
>  %      although we should be careful to pinpoint these as the source of
>  %      the error (no impurity allowed in closures) rather than as
>  %      errors to be corrected.
> +%      (XXX is the above comment still correct now that we support
> +%      impure closures?)

I think it can be removed.

> Index: compiler/simplify.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
> retrieving revision 1.106
> diff -u -d -r1.106 simplify.m
> --- compiler/simplify.m	1 Nov 2002 07:06:57 -0000	1.106
> +++ compiler/simplify.m	22 Jan 2003 16:28:38 -0000
> @@ -726,13 +726,17 @@
>  		simplify_do_calls(Info0),
>  		% XXX We should do duplicate call elimination for
>  		% class method calls here.
> -		GenericCall = higher_order(Closure, _, _)
> +		GenericCall = higher_order(Closure, Purity, _, _),
> +		% XXX Should we handle impure/semipure higher-order calls too?
> +		Purity = (pure)

Surely not?

> Index: compiler/type_util.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/type_util.m,v
> retrieving revision 1.113
> diff -u -d -r1.113 type_util.m
> --- compiler/type_util.m	14 Jan 2003 16:42:30 -0000	1.113
> +++ compiler/type_util.m	23 Jan 2003 05:00:35 -0000
> @@ -35,14 +35,14 @@
>  :- pred type_ctor_is_atomic(type_ctor, module_info).
>  :- mode type_ctor_is_atomic(in, in) is semidet.
>  
> -	% type_is_higher_order(Type, PredOrFunc, ArgTypes) succeeds iff
> -	% Type is a higher-order predicate or function type with the specified
> +	% type_is_higher_order(Type, Purity, PredOrFunc, ArgTypes, EvalMeth) succeeds
> +	% iff Type is a higher-order predicate or function type with the specified

Wrapping.

Otherwise, this looks great.

Simon.
--------------------------------------------------------------------------
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