0 Votes

Lisp: best practices

Last modified by patrik_skogqvist on 2025/03/20 14:15

Only testing layout...

Q&A

Q: Fetching stuff from ice objects structure?

The following is done very often

(setf cfd (subcomponent building '(simulations cfd)))
(setf var1 (get-value cfd 'option1))
(setf var2 (get-value cfd 'option2))
(... var10 ...)

Is the first subcomponent call very cheap, or not? Is cfd a reference/poiner or a copy? I.e. Is it good or bad to make a function instead:

(defun get-cfd-option (building option &aux cfd ...)
   (setf cfd (subcomponent building '(simulations cfd)))
   (get-value cfd option))

(setf var1 (get-cfd-option building 'option1))
(setf var2 ...)
(setf var10 ...)

In this latter alternative, the subcomponent will be fetched for every setf. Bad or good?


 A:

 Q: Next

Text

(let ((a 'b))
   (when a
      ...))

text

 A: