kons-9 icon indicating copy to clipboard operation
kons-9 copied to clipboard

Undocumented build-time requirement on *READ-DEFAULT-FLOAT-FORMAT*

Open lukego opened this issue 1 year ago • 12 comments

Spinning out one specific issue from #177:

kons-9 compilation has an undocumented dependency on the Common Lisp variable *READ-DEFAULT-FLOAT-FORMAT* having its default value SINGLE-FLOAT. If the value is changed to DOUBLE-FLOAT then compilation fails. This issue has bitten at least two real-world users (@awolven and myself.)

This issue could be addressed in at least three different ways:

  1. Document this requirement and tell the user to take care of it.
  2. Ensure "somehow" that this variable has the required value during kons-9 compilation.
  3. Update relevant code to be agnostic to the value of this variable e.g. write 0.5f0 instead of 0.5.

Demonstration:

* (setq *read-default-float-format* 'double-float)
* (require :kons-9)
...
; compiling file "/home/luke/git/kons-9/src/kernel/point-origin.lisp" (written 14 NOV 2022 06:52:36 AM):

; file: /home/luke/git/kons-9/src/kernel/point-origin.lisp
; in: DEFUN P-SMOOTH-LERP
;     (ORIGIN.VEC3:LERP KONS-9::P1 KONS-9::P2 (KONS-9::CUBIC KONS-9::F))
; 
; caught WARNING:
;   Derived type of
;   (+ (* -2.0 (* KONS-9::X KONS-9::X KONS-9::X)) (* 3.0 (* KONS-9::X KONS-9::X)))
;   is
;     (VALUES (OR DOUBLE-FLOAT (COMPLEX DOUBLE-FLOAT)) &OPTIONAL),
;   conflicting with its asserted type
;     SINGLE-FLOAT.
;   See also:
;     The SBCL Manual, Node "Handling of Types"

; in: DEFUN P-MIDPOINT
;     (ORIGIN.VEC3:SCALE (ORIGIN.VEC3:+ KONS-9::P1 KONS-9::P2) 0.5d0)
; 
; note: deleting unreachable code
; 
; caught WARNING:
;   Constant 0.5 conflicts with its asserted type SINGLE-FLOAT.
;   See also:
;     The SBCL Manual, Node "Handling of Types"

lukego avatar Nov 14 '22 16:11 lukego