From: R. Matthew Emerson
Subject: *read-default-float-format*
Date: 
Message-ID: <873dy0tcnc.fsf@nightfly.apk.net>
I have some code like this:

(defparameter *image*
  (make-array '(8 8)
	:element-type 'single-float
	:initial-contents
		   '((139.0 144.0 149.0 153.0 155.0 155.0 155.0 155.0)
		     (144.0 151.0 153.0 156.0 159.0 156.0 156.0 156.0)
		     (150.0 155.0 160.0 163.0 158.0 156.0 156.0 156.0)
		     (159.0 161.0 162.0 160.0 160.0 159.0 159.0 159.0)
		     (159.0 160.0 161.0 162.0 162.0 155.0 155.0 155.0)
		     (161.0 161.0 161.0 161.0 160.0 157.0 157.0 157.0)
		     (162.0 162.0 161.0 163.0 162.0 157.0 157.0 157.0)
		     (162.0 162.0 161.0 161.0 163.0 158.0 158.0 158.0))))

Now, suppose I want to globally replace single-float with double-float
throughout all my declarations.  How can I temporarily bind
*read-default-float-format* to 'double-float while I compile?  I don't
want to have to write 139d0, 144d0, etc. because I want things to work
unmodified with single-float too.

I can do

(eval-when (compile)
  (setf *read-default-float-format* 'double-float))

But I would rather not have the binding changed as a side-effect
of compiling the file.

-matt
From: Barry Margolin
Subject: Re: *read-default-float-format*
Date: 
Message-ID: <CvZp3.45$ej1.7341@burlma1-snr2>
In article <··············@nightfly.apk.net>,
R. Matthew Emerson <···@nightfly.apk.net> wrote:
>Now, suppose I want to globally replace single-float with double-float
>throughout all my declarations.  How can I temporarily bind
>*read-default-float-format* to 'double-float while I compile?  I don't
>want to have to write 139d0, 144d0, etc. because I want things to work
>unmodified with single-float too.
>
>I can do
>
>(eval-when (compile)
>  (setf *read-default-float-format* 'double-float))
>
>But I would rather not have the binding changed as a side-effect
>of compiling the file.

(let ((*read-default-float-format* *read-default-float-format*))
  (compile-file "filename"))

will ensure that any changes to the variable do not persist after the
compilation.  COMPILE-FILE already does this automatically for *READTABLE*
and *PACKAGE*; I'm not sure why this wasn't done for all the other I/O
control variables.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.