4 ms·
There's no realistic danger of a Common Lisp implementation abandoning support for the text serialization of Lisp source code, because the reader is part of the
by mikelevins 9y ago
There's no realistic danger of a Common Lisp implementation abandoning support for the text serialization of Lisp source code, because the reader is part of the language spec. That being the case, you can always count on support for Lisp text files, and therefore for comments stored in them.
On the other hand, nothing in the standard forbids an implementation from keeping comments around in the image. Off the top of my head I don't know of an implementation that does it, but it might be a handy feature to have.
- lispm 9y agoComments in Interlisp weren't really magic. Basically the comment function * was taking unevaluated args as a list. An NLAMBDA. It just returned its arg. (* this is a comment in Interlisp) This means also comments could also only be used where they fit into the Lisp syntax and not changed the control flow. In Common Lisp: (defun comment (words) words) (defmacro § (&rest words) `(comment '(,@words))) (let ((a 20)) (cond ((< 0 a 10) (§ Only when A is between 0 and 10. This is a typical value.) (* a 0.1)) (t (§ a is not between 0 and 10) (* a 0.2)))) Now it would need a special pretty printer command, so that * comment lines would be layouted such that they are aligned fit on a line. * the position of the comment should stand out from the code. Interlisp had a pretty printer macro for it. It might be better to turn that into a reader macro, so that inside the comment one would then not be constrained by s-expression syntax.... Interlisp has also the feature to store/retrieve the comment text on demand from a file. Thus the comment text might not be needed to be present in the image itself.
- nibbula 9y agoI'm quite thankful that we don't have to worry about the syntactic position of comments, and the wise folks of CL, as you may know, made it so that saving comment text can be as easy as: (defparameter *comments* nil) (defun comment-saver (stream char) (declare (ignore char)) (push (list *load-pathname* (stream-file-position stream) (with-output-to-string (str) (loop :with c :while (char/= #\newline (setf c (read-char stream))) :do (write-char c str)))) *comments*) (values)) (set-macro-character #\; #'comment-saver) With apologies for boring the non-Lisp infatuated.
- mikelevins 9y agoI think that after 30 years of lively interaction, my relationship with Lisp can be considered to have gone beyond infatuation. Whether that's a good thing is debatable, of course.