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

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Mar 24 19:52:55 AEDT 2000


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

> 	#define MR_CHECK_EXPR_TYPE(expr, type) \
> 		((void) sizeof(*(type *)NULL = (expr)))

Making the change you are suggesting would reduce safety, not increase it,
since it is far more likely that another structure type has the same size
than that another structure type has a field with the same very specific name.

If you want to *add* that test beside the existing one without replacing the
existing test, go ahead, but I think the gains are not worth it.

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