[m-rev.] for review: mercury implementation of float_to_string

Simon Taylor stayl at cs.mu.OZ.AU
Sat Nov 23 02:44:33 AEDT 2002


On 22-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> Estimated hours taken: 2
> Branches: main
> 
> Provide a mercury implementation of string__float_to_string.  This is
> needed so that string__float_to_string returns the same output on all
> backends.
> 
> library/string.m:
> 	Implementation of string__float_to_string in Mercury by using
> 	string__format.
 
> Index: library/string.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/library/string.m,v
> retrieving revision 1.186
> diff -u -r1.186 string.m
> --- library/string.m	21 Nov 2002 09:21:33 -0000	1.186
> +++ library/string.m	22 Nov 2002 15:16:19 -0000
> @@ -1829,13 +1829,60 @@
>  :- pragma foreign_proc("C",
>  	string__float_to_string(Flt::in, Str::uo),
>  		[will_not_call_mercury, promise_pure, thread_safe], "{
> +	/*
> +	** For efficiency reasons we duplicate the C implementation
> +	** of string__lowlevel_float_to_string
> +	*/

It might be better to use a macro.

> +:- pred string__lowlevel_float_to_string(float, string).
> +:- mode string__lowlevel_float_to_string(in, uo) is det.

You should document the difference between lowlevel_float_to_string
and float_to_string, explaining why both are needed.

> +:- pragma foreign_proc("C",
> +	string__lowlevel_float_to_string(Flt::in, Str::uo),
> +		[will_not_call_mercury, promise_pure, thread_safe], "{
> +	/*
> +	** Note anychanges here will require the same changes in

s/anychanges/any changes/

I'm not going to be around for the next couple of days,
so someone else will have to review the follow-ups.

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