[plt-scheme] Numerical precision

From: Jos Koot (jos.koot at telefonica.net)
Date: Wed Mar 11 20:56:47 EDT 2009


----- Original Message ----- 
From: "Will M. Farr" <farr at mit.edu>
To: "Jos Koot" <jos.koot at telefonica.net>
Cc: "Jaime Vargas" <jev at mac.com>; "PLT-list" <plt-scheme at list.cs.brown.edu>; 
"Joe Marshall" <jmarshall at alum.mit.edu>
Sent: Wednesday, March 11, 2009 11:43 PM
Subject: Re: [plt-scheme] Numerical precision

On Wed, Mar 11, 2009 at 6:39 PM, Jos Koot <jos.koot at telefonica.net> wrote:
> (define numerical-precision
> (make-parameter #f
> (lambda (p)
> (set! N (expt 10 p))
> (set! 1/N (/ N))
> p)))
> (define N #f)
> (define 1/N #f)
> (numerical-precision 2)

This defeats the purpose of parameters.  Try it with multiple threads,
or inside a (parameterize ...) form with non-local exits, and you'll
get a surprise, I think.  In these instances, separate locations are
created for the parameter in each thread/parameterize form, but you
are using the same location for N and 1/N across all threads.


Posted on the users mailing list.