5 ms·
nitpicking, but I am not a fan of the naming. No need of a capital "A" and no need to recall the class name in the accessor names: "var" instead of "a-var" is e
by vindarel 2y ago
nitpicking, but I am not a fan of the naming. No need of a capital "A" and no need to recall the class name in the accessor names: "var" instead of "a-var" is enough, since yes, we can very well have an accessor "var" for a class "b". "var" is a generic function. So:
(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.html https://lispcookbook.github.io/cl-cookbook/editor-support.ht...
https://github.com/CodyReichert/awesome-cl https://github.com/CodyReichert/awesome-cl
- amno 2y agoI am with you, I think setf is making code repetitive and more verbose in many cases, however in this particular case, if you see (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.
- vindarel 2y agoSince I was talking about accessors / generic functions, I don't get the point of this example: (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")