[m-rev.] diff: implement typeinfo_is_variable in C#

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 14 00:51:16 AEDT 2003

On 13-Nov-2003, Peter Ross <pro at missioncriticalit.com> wrote:
> -:- pragma foreign_proc("MC++",
> +:- pragma foreign_proc("C#",
>  	typeinfo_is_variable(TypeInfo::in, VarNum::out), [promise_pure], "
> -	SUCCESS_INDICATOR = (dynamic_cast<MR_Word>(TypeInfo) == NULL);
> -		VarNum = System::Convert::ToInt32(TypeInfo);
> +	try {
> +		VarNum = System.Convert.ToInt32(TypeInfo);

It would make more sense to swap the order of those two lines,
so that the line SUCCESS_INDICATOR = true is only executed in the
case where the cast succeeds, not in the case where it fails.
(The efficiency difference is minor, but I think it would be
easier to read this way.)

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