[plt-scheme] Numerical precision

From: Will M. Farr (farr at mit.edu)
Date: Wed Mar 11 18:43:27 EDT 2009

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.

Will


Posted on the users mailing list.