[racket] a small itch regarding flonums

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed May 18 19:31:50 EDT 2011

At Mon, 16 May 2011 21:09:39 +0200, Stephan Houben wrote:
> Hi list,
> 
> Let me first say that Racket is really great, and that I like it a lot.
> However, the other day I found something which made me wonder.
> 
> fl+ , fl* etc. in racket/flonum take only 2 arguments,
> while fl+ etc. in rnrs/arithmetic/flonums-6 take an
> arbitrary number of arguments, just like +.
> 
> Why this difference? It looks like the r6rs fl+ gets open-coded
> with some macro wizardry so there shouldn't be a performance penalty, right?

I think it actually isn't. When you apply the R6RS `fl+' to two
arguments, it's the Racket `fl+'. Otherwise, `fl+' calls a function
that checks all arguments and then just uses `+'.

An obstacle to converting `fl+' to multiple `fl+' calls at the Racket
level is the error message when the wrong sort of value is provided as
one argument. I've considered making the error messages worse --- not
mentioning the other arguments --- when reporting a bad argument, and
then the error message wouldn't change if the arguments are rearranged.
For now, though, I've opted to have only a two-argument `fl+'.



Posted on the users mailing list.