[m-dev.] for review: MR_TypeInfo cleanup, part 1

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 24 21:21:08 AEDT 2000


On 24-Mar-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 24-Mar-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > One small drawback with this technique is that it depends for its correctness
> > on the named field (e.g. `arity' or `type_ctor_desc_dummy_field') being the
> > *first* field in the type.  Another minor drawback is that it only guarantees
> > that the type is a type with the given field name, not that it is the correct
> > type.
> 
> The field is named "type_ctor_desc_dummy_field". The name can be trivially
> changed to "type_ctor_desc_dummy_field_which_must_be_first", if you like, to
> address your first point.

Using such long field names would be cumbersome; it would be
better to simply document that fact (and the reason for it)
at the point where the field is defined.

But I think using the MR_CHECK_EXPR_TYPE() macro that I suggested
would be a more elegant solution.

> The first part of the name solves the problem
> addressed by your second point, unless a review lets through some badly
> misnamed fields in future changes.

Well, you're using the same technique in MR_TYPECTOR_DESC_MAKE_FIRST_ORDER(),

|	#define MR_TYPECTOR_DESC_MAKE_FIRST_ORDER(type_ctor_info)     \
|	       ( (MR_TypeCtorDesc) &type_ctor_info->arity )

and in this case the field name is `arity', which is used not just in
MR_TypeCtorInfo, but also in several other structs that we define:
MR_TypeLayout_FunctorDescriptor, ML_Construct_Info, and ML_Expand_Info.

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