[m-rev.] for review: allow promise_pure and promise_semipure attributes
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Nov 15 06:17:22 AEDT 2001
On 14-Nov-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 6
> Branches: main
>
> Accept promise_pure and promise_semipure as foreign proc attributes.
> Make changes required to make pragma foreign_proc impure by default,
> but leave the actual default setting commented out for now.
> Index: compiler/prog_data.m
> ===================================================================
> attributes_to_strings(Attrs, StringList) :-
> % We ignore Lang because it isn't an attribute that you can put
> % in the attribute list -- the foreign language specifier string
> % is at the start of the pragma.
> Attrs = attributes(_Lang, MayCallMercury, ThreadSafe, TabledForIO,
> - ExtraAttributes),
> + Purity, ExtraAttributes),
> (
> MayCallMercury = may_call_mercury,
> MayCallMercuryStr = "may_call_mercury"
> @@ -1061,7 +1079,18 @@
> TabledForIO = not_tabled_for_io,
> TabledForIOStr = "not_tabled_for_io"
> ),
> - StringList = [MayCallMercuryStr, ThreadSafeStr, TabledForIOStr] ++
> + (
> + Purity = pure,
> + PurityStr = "promise_pure"
> + ;
> + Purity = (semipure),
> + PurityStr = "promise_semipure"
> + ;
> + Purity = (impure),
> + PurityStr = ""
> + ),
> + StringList = [MayCallMercuryStr, ThreadSafeStr, TabledForIOStr,
> + PurityStr] ++
> list__map(extra_attribute_to_string, ExtraAttributes).
The `impure' case should probably be handled by having no purity entry
in StringList, not an empty string.
> Index: doc/reference_manual.texi
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
> retrieving revision 1.224
> diff -u -r1.224 reference_manual.texi
> --- doc/reference_manual.texi 12 Nov 2001 11:08:13 -0000 1.224
> +++ doc/reference_manual.texi 13 Nov 2001 08:38:02 -0000
> @@ -4831,6 +4831,13 @@
> corresponding to their Mercury types, as determined by language and
> implementation specific rules.
>
> + at c All @samp{foreign_proc} implementations are assumed to be impure.
> + at c If they are actually pure or semipure, they must be explicitly
> + at c promised as such by the user (either by using foreign language
> + at c attributes specified below, or a promise_pure or promise_semipure pragma
> + at c as specificed in the ``Purity'' chapter of the Mercury Language
> + at c Reference Manual).
s/specificed/specified/
Use a Texinfo cross reference command here:
+ at c attributes specified below, or a promise_pure or promise_semipure pragma
+ at c as specified in @ref{Impurity}.
> depend on the foreign language and compilation options.
> For more information, including the list of supported foreign languages and
> @@ -4889,15 +4896,16 @@
>
> @table @asis
>
> - at item @samp{may_call_mercury}/@samp{will_not_call_mercury}
> -This attribute declares whether or not execution inside this foreign
> -language code may call back into Mercury or not. The default, in case
> -neither is specified, is @samp{may_call_mercury}.
> -Specifying @samp{will_not_call_mercury} may allow the compiler to
> -generate more efficient code.
> -If you specify @samp{will_not_call_mercury},
> -but the foreign language code @emph{does} invoke Mercury code, then the
> -behaviour is undefined.
Was this change intentional?
> + at item @samp{promise_pure}/@samp{promise_semipure}
> +This attribute promises that the purity of the given predicate or
> +function definition is pure or semipure.
> +It is equivalent to a corresponding @samp{pragma promise_pure}
> +or at samp{pragma promise_semipure} declaration (see the ``Purity'' chapter
> +of the Mercury Language Reference Manual for further details).
Missing space between `or' and `@samp'.
Use Texinfo cross references -- replace the part in brackets
with @pxref{Impurity}.
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