[m-rev.] For review: deconstruct non-canonical terms in pretty_printer.m

Mark Brown mark at csse.unimelb.edu.au
Mon Oct 8 15:54:21 AEST 2007


On 08-Oct-2007, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> Index: library/pretty_printer.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/library/pretty_printer.m,v
> retrieving revision 1.6
> diff -u -r1.6 pretty_printer.m
> --- library/pretty_printer.m	3 Sep 2007 16:41:41 -0000	1.6
> +++ library/pretty_printer.m	8 Oct 2007 04:05:09 -0000
> @@ -645,7 +645,18 @@
>          Doc = set_formatting_limit_correctly(!.Limit,
>              Formatter(Univ, ArgTypeDescs))
>        else
> -        deconstruct(univ_value(Univ), canonicalize, Name, _Arity, Args),
> +        % We justify this promise on the grounds that
> +        % (a) observers of views of non-canonical values should give
> +        % them the same denotation,
> +        % (b) practically it is far more useful to see the construction
> +        % of non-canonical values (e.g., when debugging programs), and
> +        % (c) propagating cc_multi all the way up into the interface could
> +        % make use of the pretty printer very awkward.
> +        %
> +        promise_equivalent_solutions [Name, Args] (
> +            deconstruct(univ_value(Univ), include_details_cc,
> +                Name, _Arity, Args)
> +        ),

In view of the followup discussion on the developers list, i think you
should:

    - Add the promise here, and add a comment to say that the promise is
      valid because of the way that we interpret equality on the doc type.

    - Document in the interface that the intended interpretation of equality
      on type doc is that docs are equal if they describe the same logical
      document, and in particular that docs created with format/1 are equal
      if the terms are equal.

    - Also document that we don't actually implement this version of
      equality, and enjoin users to avoid it.  It would help to give the
      example of two docs created from equal non-canonical terms being equal
      according to the intended interpretation, but failing a test
      unification.

    - Make format/8 cc_multi.  Use cc_multi_equal at an appropriate point.

    - I would suggest adding format_io/8, which is specialised to the io
      stream, and which is det.  This will need a promise too: document
      that this promise is safe because we can never test io streams for
      equality.

    - If you actually do need a string stream, we can discuss that next.

Cheers,
Mark.

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