Open aartaka opened 1 year ago
Agree it's a nice thing :)
I wonder if it's possible though. Take a slot that has the :reader
initform.
(malignant-slot :reader "My docstring")
Kaboom! :p
Yes, but for such cases one's better off using a regular :initform
/:documentation
syntax because it's ambiguous. We can't provide any guarantees for such use :P
Other than that extreme corner-case, the thing is relatively doable with e.g. pattern matching.
Let's not introduce a library for just this, it's easy enough to check if the 3rd element is a string and the second is not a keyword.
I think the following check would work:
(and
(oddp (length DEFINITION))
(not (keywordp (nth 1 DEFINITION)))
(stringp (nth 2 DEFINITION))
Alternatively, check that the second element is not in
(append '(:accessor :initarg :initform) *allowed-slot-definition-properties*)
Yes, fair.
I've been bringing this up here and there, but here's a PR.
I believe it would be an aesthetic and useful change allowing inline documentation in our custom syntax for class definitions, like
This is going to cut some lines of code for short slots and make long slots slightly easier to follow when used to.
But, obviously, it causes quite some trouble for slot parsing, which is already quite complex.
If we agree that this is something we want, I'm ready to prototype this thing with all the caution left in me :P