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

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Jan 5 13:19:35 AEDT 2007


On Fri, 5 Jan 2007, Simon Taylor wrote:

> On 02-Jan-2007, Julien Fischer <juliensf at csse.unimelb.edu.au> 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.
>>
>> I suggest also add det_num_functors that does the same thing except
>> that it throws an exception rather than failing.
>
> Done.
>
>>> Index: NEWS
>>> ===================================================================
>>> RCS file: /home/mercury1/repository/mercury/NEWS,v
>>> retrieving revision 1.433
>>> diff -u -u -r1.433 NEWS
>>> --- NEWS	21 Dec 2006 03:00:48 -0000	1.433
>>> +++ NEWS	28 Dec 2006 12:45:54 -0000
>>> @@ -40,6 +40,16 @@
>>> * The type software_error/0 has been moved from the require module into
>>>  the exception module.
>>>
>>> +* construct.num_functors now fails rather than returning -1 for types
>>> +  with no functors.
>>
>> Append the arity to num_functors.
>
> Done.
>
> Ralph Becket wrote:
>> Taking this line, the documentation for num_functors should include this
>> justification.  Julien and I spent about ten minutes trying to work this
>> out from the source code, but couldn't find an explanation.
>
> Done.
>
> Simon.
>
>
> diff -u NEWS NEWS
> --- NEWS
> +++ NEWS
> @@ -43,11 +43,12 @@
> * The type software_error/0 has been moved from the require module into
>   the exception module.
>
> -* construct.num_functors now fails rather than returning -1 for types
> -  with no functors.
> +* construct.num_functors/1 now fails rather than returning -1 for types
> +  with no functors.  There is a new function construct.det_num_functors/1
> +  which aborts for types with no functors.
>
> * We have added predicates deconstruct.functor_number/3 and
> -  deconstruct.deconstruct_du/4 which return functor numbers suiable
> +  deconstruct.deconstruct_du/4 which return functor numbers suitable
>   for use by construct.construct, rather than functor strings.
>
> * We have added a function construct.get_functor_lex/2 which converts
> diff -u library/construct.m library/construct.m
> --- library/construct.m
> +++ library/construct.m
> @@ -35,11 +35,17 @@
>     % num_functors(TypeInfo).
>     %
>     % Returns the number of different functors for the top-level
> -    % type constructor of the type specified by TypeInfo, or -1
> +    % type constructor of the type specified by TypeInfo, or fail
>     % if the type is not a discriminated union type.
>     %

I suggest making the last bit a separate sentence, e.g.

 	Returns the number of different functors for the top-level
 	type constructor of the type specified by TypeInfo.
 	Fails if the type is not a discriminated union type.

Also, s/TypeInfo/TypeDesc/

(At the very least you need one of: s/Returns/Return/ or s/fail/fails/.)

That looks fine otherwise.

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