[m-rev.] diff: handle user defined equality in rtti_implementation__deconstruct

Peter Ross pro at missioncriticalit.com
Sat Nov 30 05:00:12 AEDT 2002


fjh wrote:
> On 29-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > +handle_usereq_type(Term, TypeInfo, TypeCtorInfo,
> > + TypeCtorRep, NonCanon, Functor, Arity, Arguments) :-
> > + ( NonCanon = do_not_allow,
> > + error("attempt to deconstruct noncanonical term")
> > + ; NonCanon = canonicalize,
> > + Functor = expand_type_name(TypeCtorInfo, yes),
> > + Arity = 0,
> > + Arguments = []
>
> The two lines above look wrong -- there should at least be an XXX comment
> there.
>
        case MR_TYPECTOR_REP_ENUM_USEREQ:
            if (noncanon == MR_NONCANON_ABORT) {
                /* XXX should throw an exception */
                MR_fatal_error(MR_STRINGIFY(EXPAND_FUNCTION_NAME)
                    ": attempt to deconstruct noncanonical term");
                break;
            } else if (noncanon == MR_NONCANON_ALLOW) {
                handle_noncanonical_name(type_ctor_info);
                handle_zero_arity_args();
                break;
            }
            /* else fall through */

        case MR_TYPECTOR_REP_ENUM:
            handle_functor_name(MR_type_ctor_layout(type_ctor_info).
                    MR_layout_enum[*data_word_ptr]->MR_enum_functor_name);
            handle_zero_arity_args();
            break;

Here is the C code from mercury_ml_expand_body.  As you can see in
MR_NONCANON_ALLOW case, we expand the type name and return 0 arity.
Consequently the Arguments should be the empty list.

> > + ; NonCanon = include_details_cc,
> > + deconstruct(Term, TypeInfo, TypeCtorInfo, TypeCtorRep,
> > + NonCanon, Functor, Arity, Arguments)
>
> Isn't that going to result in an infinite loop, handle_usereq_type/7 calls
> deconstruct/7 calls handle_usereq_type/7 calls deconstruct/7 ...?
>
No it will not.  You call handle_usereq_type with the type_ctor_rep which is
the `base' type_ctor_rep for the specified type_ctor_rep.  For example if
you are handling the notag_usereq type, then you pass to handle_user_eq the
type_ctor_rep notag.  I will add a comment to that effect to this code.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.423 / Virus Database: 238 - Release Date: 27/11/2002

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