[m-rev.] diff: implement deconstruct for arrays in mercury

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Dec 3 16:06:45 AEDT 2002


On 02-Dec-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> +++ rtti_implementation.m	2 Dec 2002 17:21:07 -0000
> @@ -813,9 +813,20 @@
>  		Arguments = []
>  	;
>  		TypeCtorRep = array,
> +		det_dynamic_cast(Term, Array),
> +		std_util__type_ctor_and_args(std_util__type_of(Term), _, Args),
> +		( Args = [ElemType] ->
> +			std_util__has_type(Elem, ElemType),
> +			same_array_elem_type(Array, Elem)
> +		;
> +			error("An array which doesn't have type_ctor arg")
> +		),

IMHO it would be clearer to write this code with the call to det_dynamic_cast
after the if-then-else here.  That's the order in which the code will
actually be invoked; the Mercury compiler will delay the call to
det_dynamic_cast until after the call to `has_type'.

Otherwise that looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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