[asdf-devel] Apply *read-default-float-format* to lisp files

Richard M Kreuter kreuter at progn.net
Fri Jul 17 22:12:27 UTC 2009


Brett van de Sande writes:
> 
> I have some lisp source files that contain some (many)
> floating point numbers.  How can I use asdf to ensure
> these files are read using (setf *read-default-float-format* 'double-float)
> without setting *read-default-float-format* globally?

One straightforward way to do this is to subclass CL-SOURCE-FILE and add
:AROUND methods for OPERATE that rebind *READ-DEFAULT-FLOAT-FORMAT*.
Some systems do the analogous thing to rebind *READTABLE*, I believe.

Untested example below.

Regards,
Richard

(defclass cl-source-file-with-read-float-format-rebinding
    (asdf:cl-source-file)
  ())

(defmethod operate :around
    ((o asdf:compile-op)
     (c cl-source-file-with-read-float-format-rebinding))
  (let ((*read-default-float-format* 'double-float))
    (call-next-method)))
  

(defmethod operate :around
    ((o asdf:load-op)
     (c cl-source-file-with-read-float-format-rebinding))
  (let ((*read-default-float-format* 'double-float))
    (call-next-method)))

(defmethod operate :around
    ((o asdf:load-source-op)
     (c cl-source-file-with-read-float-format-rebinding))
  (let ((*read-default-float-format* 'double-float))
    (call-next-method)))




More information about the asdf-devel mailing list