[m-dev.] for review: change typeclass_info structure
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Apr 3 19:18:41 AEST 2000
On 31-Mar-2000, David Glen JEFFERY <dgj at cs.mu.OZ.AU> wrote:
> Index: compiler/polymorphism.m
> @@ -2134,10 +2025,14 @@
> % already been reversed, so lets
> % reverse them back.
> list__reverse(TypeInfoGoals, RevTypeInfoGoals),
> + list__reverse(UnconstrainedTypeInfoGoals,
> + RevUnconstrainedTypeInfoGoals),
>
> list__append(ExtraGoals1, RevTypeInfoGoals,
> ExtraGoals2),
> - list__append(NewGoals, ExtraGoals2, ExtraGoals)
> + list__append(NewGoals, ExtraGoals2, ExtraGoals3),
> + list__append(RevUnconstrainedTypeInfoGoals,
> + ExtraGoals3, ExtraGoals)
Hmm, the order of the goals there looks a little strange.
Why do the RevTypeInfoGoals get put at the end, whereas
the RevUnconstraintTypeInfoGoals get put at the start?
I suppose it doesn't make any difference, since mode analysis
will reorder things to ensure the correct ordering, but it
would be nicer if the order here was consistent, preferably
such that no reordering is required.
> Index: runtime/mercury_deep_copy_body.h
> ===================================================================
> RCS file: /home/staff/zs/imp/mercury/runtime/mercury_deep_copy_body.h,v
> retrieving revision 1.21
> diff -u -t -r1.21 mercury_deep_copy_body.h
> --- runtime/mercury_deep_copy_body.h 2000/03/24 10:27:47 1.21
> +++ runtime/mercury_deep_copy_body.h 2000/03/30 05:03:29
> @@ -681,6 +681,7 @@
> int num_arg_typeinfos;
> int num_super;
> int arity;
> + int num_unconstrained;
> int i;
>
> /*
> @@ -691,6 +692,9 @@
> base_typeclass_info = (Word *) *typeclass_info;
>
> arity = MR_typeclass_info_instance_arity(typeclass_info);
> + num_unconstrained =
> + MR_typeclass_info_num_extra_instance_args(typeclass_info)
> + - arity;
The name `arity' here is a bit confusing to me. What does the
`instance_arity' field of the typeclass_info actually represent?
I think perhaps `MR_typeclass_info_num_instance_constraints()' might be a
better name for that macro, and likewise `num_instance_constraints' might be a
better name for the `arity' variable here.
> num_super = MR_typeclass_info_num_superclasses(typeclass_info);
> num_arg_typeinfos = MR_typeclass_info_num_type_infos(typeclass_info);
> incr_saved_hp(LVALUE_CAST(Word, new_typeclass_info),
> @@ -698,14 +702,24 @@
>
> new_typeclass_info[0] = (Word) base_typeclass_info;
>
> + /* First, copy typeinfos for unconstrained tvars from */
> + /* the instance declaration */
That comment is not using the format for a multi-line C comment
specified in the Mercury C coding guidelines.
> + for (i = 1; i < num_unconstrained + 1; i++) {
> + new_typeclass_info[i] = (Word) copy_type_info(
> + (MR_TypeInfo *)(&typeclass_info[i]), lower_limit, upper_limit);
> + }
> + /* Next, copy all the typeclass infos */
> + for (i = num_unconstrained + 1;
> + i < num_unconstrained + arity + num_super + 1;
> + i++)
I think it would be a good idea to explain that in a little bit
more detail:
/*
** Next, copy all the typeclass infos: both the ones for
** constraints on the instance declaration (instance
** constraints), and the ones for constraints on the
** typeclass declaration (superclass constraints).
*/
> + /* Then, copy the type infos */
Likewise here:
/*
** Then, copy all the type infos for types in the
** head of the type class declaration.
*/
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list