libera/#commonlisp - IRC Chatlog
Search
8:35:33
pve
Hi, is it allowed to do (with-accessors ((name symbol-name)) 'foo (print name))? Of course doing that is silly, but it's not clear to me if it's forbidden, by reading the hyperspec page.
8:38:44
pve
the page talks about slots, accessors and instances, but does any of that apply to a symbol?
9:06:20
beach
Although the "Notes" section is not normative, you can see in the WITH-ACCESSORS dictionary entry that it expands to a SYMBOL-MACROLET, so there is no reason why it wouldn't work for SYMBOL-NAME.
9:44:02
mfiano
It is just anything that accesses, which is also defined to attempting to read or write a place
9:51:43
aeth
getter and/or setter... or in CL-specific terms, reader and/or writer. It's just that the latter is almost always via SETF.
9:53:41
aeth
Where WITH-ACCESSORS won't work is when you need more than one argument, e.g. an AREF, which is definitely an accessor. (* technically, you could use it on an AREF of 0D arrays because those have no index)
10:02:12
mfiano
It's interesting to think about how you can have a SETF-named function or method specialized to a class, that is not considered an accessor (by just returning something irrelevant and not reading from or writing to a place), or to have a class with a slot having only a :reader for its slot specifier, having a true accessor defined with it.