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

Peter Ross pro at missioncriticalit.com
Sat Nov 30 18:02:37 AEDT 2002


fjh wrote:
> On 29-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > 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.
>
> For enums, fine -- all values of enumeration types are constants
> and thus have zero arity.
>
> But the procedure you are defining here doesn't say anything in its
> name about only being valid for enums, and in your code it gets called
> for du types, not just enum types.
>
If you examine the code for all the other cases in mercury_ml_expand_body.h
it does exactly the same thing.  It may not be the correct thing to do, but
that is what the code in ml_expand_body.h does.



---
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: 28/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