Hi,
I recently posted a question at
http://stackoverflow.com/questions/12156902/unxpected-behavior-with-eval-whe...
Brief summary:
The following code should (I think) set *read-default-float-format* to double float. Well, it does compile with C-c C-k, but running
*read-default-float-format*
in the REPL afterwards gives SINGLE-FLOAT.
So the value of *read-default-float-format* in the REPL has not changed from the default value of SINGLE-FLOAT.
Note, however, that the
(print *read-default-float-format*)
in the code does return DOUBLE-FLOAT.
Rainer Joswig, in his answer to this question, says that this is because the compilation and the REPL are on different threads (if I understand him correctly), but I'd like some evidence of this. Also, this code works fine with SBCL.
In addition to wanting to understand why this is happening, I'd like to know whether it is possible to work around this, and set *read-default-float-format* in a file, rather than having to set it on the command line.
I'm not sure whether this issue has something to do with SLIME, so I'm posting here first.
Platform and versions. I'm using Debian squeeze x86. The version of SLIME is from Debian unstable, 1:20120525-2. CCL is the 1.8 release. I tried it both with the upstream binaries from http://svn.clozure.com/publicsvn/openmcl/release/1.8/linuxx86/ccl, and a binary package created by me - see Package ccl at mentors.debian.net. The result was the same in each case.
Thanks in advance. Please CC me on any reply.
Regards, Faheem
#######################################################################
(eval-when (:compile-toplevel :load-toplevel :execute) (require :asdf) (require :cl-rmath) (setf *read-default-float-format* 'double-float))
(print *read-default-float-format*)
On Thu, Aug 30 2012, Faheem Mitha wrote:
Hi,
I recently posted a question at
http://stackoverflow.com/questions/12156902/unxpected-behavior-with-eval-whe...
Brief summary:
The following code should (I think) set *read-default-float-format* to double float. Well, it does compile with C-c C-k, but running
*read-default-float-format*
in the REPL afterwards gives SINGLE-FLOAT.
So the value of *read-default-float-format* in the REPL has not changed from the default value of SINGLE-FLOAT.
Note, however, that the
(print *read-default-float-format*)
in the code does return DOUBLE-FLOAT.
Rainer Joswig, in his answer to this question, says that this is because the compilation and the REPL are on different threads (if I understand him correctly), but I'd like some evidence of this.
SLIME creates a new thread for C-c C-k. As compiling could potentially take a long time, using a new thread seems like a reasonable thing to do. Therefore the code that compiles and loads your code is a different thread than the REPL thread.
For evidence, evaluate (princ ccl:*current-process*) in the REPL and inside the eval-when form.
Also, this code works fine with SBCL.
In addition to wanting to understand why this is happening, I'd like to know whether it is possible to work around this, and set *read-default-float-format* in a file, rather than having to set it on the command line.
I'm not sure whether this issue has something to do with SLIME, so I'm posting here first.
Platform and versions. I'm using Debian squeeze x86. The version of SLIME is from Debian unstable, 1:20120525-2. CCL is the 1.8 release. I tried it both with the upstream binaries from http://svn.clozure.com/publicsvn/openmcl/release/1.8/linuxx86/ccl, and a binary package created by me - see Package ccl at mentors.debian.net. The result was the same in each case.
Thanks in advance. Please CC me on any reply.
When CCL creates a new thread it binds some special variables in the new thread. *READ-DEFAULT-FLOAT-FORMAT* is one of them. You can see the full list of those variables with (ccl::standard-initial-bindings). Also look at the documentation of MAKE-PROCESS[1]. I think CCL:DEF-STANDARD-INITIAL-BINDING can be used to change those variables for future thread, but I know no easy way to change them in all existing threads.
Helmut
[1] http://ccl.clozure.com/ccl-documentation.html#f_make-process