numericals
numericals copied to clipboard
define-optimizable-variable: Mix symbol macros and dynamic variables
This PR adds a define-optimizable-variable macro to common.lisp that mixes symbol macros and dynamic variables. This retains the "local but global" benefit of dynamically bound variables, but allows optimizing using symbol macros when required.
For example, with the changes to src/transcendental/one-arg-fn-float.lisp,
CL-USER> EXCL> (setf numericals:*broadcast-automatically* nil)
NIL
CL-USER> (lambda (x)
(declare (optimize speed)
(type (simple-array single-float 1) x))
(numericals:sin x :out x))
; Emits compiler notes
CL-USER> (symbol-macrolet ((numericals:broadcast-automatically nil))
(lambda (x)
(declare (optimize speed)
(type (simple-array single-float 1) x))
(numericals:sin x :out x)))
; Does not emit compiler notes and optimizes with :broadcast set to NIL
@kchanqvq, this should address the issue about the unoptimizability of nu:*broadcast-automatically* you had pointed out at https://github.com/digikar99/numericals/issues/23#issuecomment-2795751916. Once you are free, let me know your thoughts on this.