[m-rev.] for review: deconstruct by functor number

Simon Taylor staylr at gmail.com
Tue Jan 2 23:27:12 AEDT 2007


On 02-Jan-2007, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
> Julien Fischer, Tuesday,  2 January 2007:
> > 
> > On Fri, 29 Dec 2006, Simon Taylor wrote:
> > >
> > >library/construct.m:
> > >library/term.m:
> > >browser/term_rep.m:
> > >	Add a function get_functor_lex, which returns the lexicographic
> > >	functor number given an ordinal functor number.
> > >
> > >	Add equivalence types to make it clearer which ordering is
> > >	being used by which functor numbers.
> > >
> > >	Remove a C-ism: num_functors now fails rather than returning -1
> > >	for types without functors.
> 
> Why wouldn't num_functors just return 0 for such types?  I don't
> understand this behaviour.

The intention is that if num_functors succeeds, other functions which
only work for discriminated union types can be used.  There are very
few situations in which you want to use the result of num_functors
without testing that it is greater than zero.  I'd also argue that
it doesn't make sense to talk about the number of functors of type
`float', it just doesn't have functors at all.

Also, it would be better to leave the interface alone rather than
changing the return value because that change is more likely to
silently break code rather than causing an error.

Simon.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list