[m-rev.] for review: specify tabling extra arguments by address

Zoltan Somogyi zs at csse.unimelb.edu.au
Fri Nov 16 13:31:47 AEDT 2007


On 16-Nov-2007, Peter Wang <novalazy at gmail.com> wrote:
> Add an optional argument to the `specified' attribute of `pragma memo' that
> allows the user to choose to table arguments introduced by the polymorphism
> transformation by address instead of by value.  e.g.

> --- compiler/hlds_out.m	12 Nov 2007 03:52:42 -0000	1.437
> +++ compiler/hlds_out.m	16 Nov 2007 01:24:18 -0000
> @@ -3676,11 +3676,17 @@
>          Strictness = all_fast_loose,
>          io.write_string("% all fast_loose\n", !IO)
>      ;
> -        Strictness = specified(ArgMethods),
> -        write_arg_tabling_methods("", ArgMethods, !IO),
> +        Strictness = specified(ArgMethods, HiddenArgMethod),
>          io.write_string("% specified [", !IO),
> -
> -        io.write_string("]\n", !IO)
> +        write_arg_tabling_methods("", ArgMethods, !IO),
> +        io.write_string("]", !IO),
> +        (
> +            HiddenArgMethod = hidden_arg_value,
> +            io.write_string("\n", !IO)
> +        ;
> +            HiddenArgMethod = hidden_arg_addr,
> +            io.write_string(", hidden args by addr\n", !IO)

I think hidden_arg_value should also be printed.

> +++ compiler/mercury_to_mercury.m	16 Nov 2007 01:24:18 -0000
> @@ -628,11 +628,20 @@
>                      Strictness = all_fast_loose,
>                      !:Strs = ["fast_loose" | !.Strs]
>                  ;
> -                    Strictness = specified(Args),
> +                    Strictness = specified(Args, HiddenArgMethod),
>                      ArgStrs = list.map(maybe_arg_tabling_method_to_string,
>                          Args),
>                      ArgsStr = string.join_list(", ", ArgStrs),
> -                    !:Strs = ["specified(" ++ ArgsStr ++ ")" | !.Strs]
> +                    (
> +                        HiddenArgMethod = hidden_arg_value,
> +                        HiddenArgStr = ""
> +                    ;
> +                        HiddenArgMethod = hidden_arg_addr,
> +                        HiddenArgStr = ", hidden_arg_addr"
> +                    ),
> +                    SpecifiedStr = "specified([" ++ ArgsStr ++ "]" ++
> +                        HiddenArgStr ++ ")",
> +                    !:Strs = [SpecifiedStr | !.Strs]

Here too.

> -        Args = [Arg],
> -        convert_list(Arg, parse_arg_tabling_method,
> +        Args = [Arg1 | MoreArgs],
> +        convert_list(Arg1, parse_arg_tabling_method,
>              "expected argument tabling method", MaybeMaybeArgMethods),
>          (
>              MaybeMaybeArgMethods = ok1(MaybeArgMethods),
>              ( eval_method_allows_fast_loose(EvalMethod) = yes ->
> -                Attribute = attr_strictness(specified(MaybeArgMethods)),
> -                MaybeTermAttribute = ok1(Term - Attribute)
> +                (
> +                    MoreArgs = [],
> +                    Attribute = attr_strictness(specified(MaybeArgMethods,
> +                        hidden_arg_value)),
> +                    MaybeTermAttribute = ok1(Term - Attribute)
> +                ;
> +                    MoreArgs = [Arg2],
> +                    (
> +                        Arg2 = term.functor(
> +                            term.atom("hidden_arg_addr"), [], _)
> +                    ->
> +                        Attribute = attr_strictness(specified(MaybeArgMethods,
> +                            hidden_arg_addr)),
> +                        MaybeTermAttribute = ok1(Term - Attribute)
> +                    ;
> +                        Msg = "expected hidden argument tabling method",
> +                        MaybeTermAttribute = error1([Msg - Arg2])
> +                    )

And here an explicit hidden_arg_value should also be accepted.

> +                ;
> +                    MoreArgs = [_, _ | _],
> +                    Msg = "expected fewer arguments",
> +                    MaybeTermAttribute = error1([Msg - Term])

Should say "one or two", not "fewer".

Otherwise, the diff is fine.

Zoltan.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list