[m-rev.] for review: printing higher order values and typeinfos in the debugger

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Mar 12 00:44:10 AEDT 2002


On 25-Feb-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> > For example, if I have
> > 
> > 	:- type foo(X, Y) == bar(Y, X).
> > 
> > then the type constructor foo/2 is definitely not equivalent to
> > the type constructor bar/2.
> 
> Ok, that convinces me. I don't know why, but I didn't even think about
> switching tvars like that.
> 
> > This is wrong because it uses MR_collapse_ctor_equivalences().
> 
> Is simply returning the name of the type_ctor_info the right thing then?

Yes.  Conceptually, you can think of the `type_info' type having
a user-defined equality, but the `type_ctor_info' type being just
a normal type.

> I think it is, because I don't think we have any mechanism that allows users
> (as opposed to implementors) to extract a type_ctor_info from a type_info.

Actually we do -- the reverse mode of std_util__make_type/2 --
but that's OK, because it is cc_multi.

> Here is the proposed diff.
> +++ runtime/mercury_deconstruct.c	2002/02/24 13:56:10
...
> @@ -288,11 +289,17 @@
>      MR_allocate_aligned_string_msg(str, len, "MR_expand_type_name");
>      MR_save_transient_hp();
>  
> +    if (wrap) {
>      sprintf(str, "<<%s:%s/%d>>",
>          tci->MR_type_ctor_module_name,
>          tci->MR_type_ctor_name,
>          tci->MR_type_ctor_arity);
> -
> +    } else {
> +        sprintf(str, "%s:%s/%d",
> +            tci->MR_type_ctor_module_name,
> +            tci->MR_type_ctor_name,
> +            tci->MR_type_ctor_arity);
> +    }

I probably would have written that as

      sprintf(str,
      	  (wrap ? "<<%s:%s/%d>>" : "%s:%s/%d"),
          tci->MR_type_ctor_module_name,
          tci->MR_type_ctor_name,
          tci->MR_type_ctor_arity);

but it's very much a matter of taste.

The diff looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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