[m-rev.] For review: more fixes to impurity

Julien Fischer juliensf at cs.mu.OZ.AU
Fri Nov 18 17:04:18 AEDT 2005


On Fri, 18 Nov 2005, Ralph Becket wrote:

> Julien Fischer, Friday, 18 November 2005:
> > On Fri, 18 Nov 2005, Ralph Becket wrote:
> >
> > > Estimated hours taken: 2
> > > Branches: main
> > >
> > > Remove now incorrect errors of the form "unification with expression was
> > > declared impure, but expression was not a function call."
> > >
> > > compiler/purity.m:
> > > 	Prevent purity.m from reporting unifications marked with
> > > 	impure as errors: unifications *can* be impure if they
> > > 	unify two inst any variables in a negated context.  Purity
> > > 	error reporting for unifications is now handled in modecheck_unify.m.
> > >
> > The fact that unifications can now have purity annotations attached to
> > them should be mentioned in the purity section of the reference manual.
> > >
> > You will probably also need to have a look at
> > tests/warnings/purity_warnings as well.
>
> How about this:
>
> unchanged:
> --- doc/reference_manual.texi	16 Nov 2005 07:02:00 -0000	1.337
> +++ doc/reference_manual.texi	18 Nov 2005 05:53:23 -0000

...

> +If predicate @code{p/N} is declared to be @code{impure} (@code{semipure})
> +then all calls to @code{p/N} must be annotated with @code{impure}
> +(@code{semipure}):
> +
> + at start example
> +	impure p(X1, X2, ..., XN)
> + at end example
> +
> +If function @code{f/N} is declared to be @code{impure} (@code{semipure})
> +then all applications of @code{f/N} must be obtained by unification with a
> +variable and the unification goal as a whole be annotated with @code{impure}
> +
> + at start example
> +	impure X = f(X1, X2, ..., XN)
> + at end example
> +
> +Any call or unification goal containing a non-local variable with inst any that
> +appears in a negated context (i.e., in a negation or the condition of an
> +if-then-else goal) must be given an @code{impure} annotation because it may
> +violate referential transparency.
> +
> +Compound goals should not have impurity annotations.
> +
> +The compiler will report an error if a required impurity annotation is

Should that be s/impurity/purity/ there since that should also cover
semipure annotations on semipure goals?

> +omitted from a call or unification goal or if a @code{semipure} annotation
> +is used where an @code{impure} annotation is required.  The compiler will
> +report a warning if a semipure goal is annotated with @{impure} or a pure goal
> +is annotated with @code{semipure}
>
>  The requirement that impure or semipure calls be marked with
>  @code{impure} or @code{semipure} allows someone

That looks ok otherwise.

Julien.


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