[slime-devel] unexpected behavior of eval-when with CCL when compiling with C-c C-k

Helmut Eller heller at common-lisp.net
Fri Aug 31 17:51:09 UTC 2012


On Thu, Aug 30 2012, Faheem Mitha wrote:

> Hi Helmut,
>
> Thanks very much for the detailed and helpful reply.
>
> May I post this as an answer to the SO question?

Sure.

>
>> 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.
>
> When it says MAKE-PROCESS here, it actually means thread, right? This
> terminology is a little confusing.

Yes, the process terminology stems from the Lisp machine era.

> The documentation says "See DEF-STANDARD-INITIAL-BINDING" but there is
> no further information about DEF-STANDARD-INITIAL-BINDING that I could
> find.

Well, CCL comes with source code.  Which in this case is not that hard
to read.  If you want to have some official documentation, it's probably
the best to create a ticket in the CCL bug tracker.

> It seems this is a function. I found one example of usage which
> looks like
>
>  (ccl::def-standard-initial-binding *read-default-float-format* 'double-float)
>
> Is this correct usage? > So, this changes the default value of
> *read-default-float-format* for all future threads?

Yes, I think so.  

> Should this be
> called in CCL's init file or somewhere else?

Yes, that should work or the ~/.swank.lisp file.

> One last question, which is tangentially related. Is there some easy
> way to find out what CCL (or, more generally, any CL implementation)
> function is called by C-c C-k?

It's a somewhat long sequence but not that hard to discover: 

1. C-c C-k invokes the command slime-compile-and-load-file.
   You can find that out with C-h k C-c C-k.

2. Looking at the source of slime-compile-and-load-file
   we see that it calls slime-compile-file, which it turn
   uses (slime-eval-async `(swank:compile-file-for-emacs ...) ...)

3. swank:compile-file-for-emacs is a CL function in swank.lisp.  SLIME's
   M-. should take you right to the source.  Reading a bit further
   reveals that this calls swank-backend:swank-compile-file which is
   defined in swank-backend.lisp but it's actually implemented in
   swank-ccl.lisp.

In the *slime-events* buffer you can see the actual messages that are
exchanged between Emacs and Lisp.  E.g. C-c C-k will send something
like

(:emacs-rex
 (swank:compile-file-for-emacs "/tmp/x.lisp" t)
 nil t 14)

Helmut





More information about the slime-devel mailing list