by vindarel · 2y ago · 0 comments
(defclass a ()
((var :accessor var)))
(var *some-a-object*) ;; => ok
(defclass b ()
((var :accessor var)))
(var *some-b-object*) ;; => ok
> If we don’t like using car to indicate the head of a list… then we can use `first` (and second, third… up to 9nth).
---
https://lispcookbook.github.io/cl-cookbook/editor-support.ht...
(var *some-object* value)
somewhere far away from the class definition, say in another file, can you tell immediately what that code does? Can you understand it directly by looking at the code? Do you define something? Do you set something or do you just read something like a property list (something like rassoc)? (setf (var *some-object*) value)
With setf it is immediately clear from the code what is going on. I don't know if that is the best example, just thinking of all the arguments for and against setf :). Personally, I find it makes code more verbose in many situations. (var *some-object* value)
because we also use SETF with accessors: (setf (var *some-object*) value)
Quick example: (defclass person ()
((name :accessor name)))
(make-instance 'person)
(setf (name *) "me")