#:g1: インラインコメントのインデント

Posted 2011-11-28 22:03:00 GMT


Single-semicolon comments are all aligned to the same column at the right;
 usually each comment concerns only the code it is next to.
Occasionally a comment is long enough to occupy two or three lines;
 in this case, it is conventional to indent the continued lines of
 the comment one space (after the semicolon).
という風にCLtL2にも紹介されているのですが、2行目以降がダブルクォートなので、ちょっと判りづらいですね。 このコード例だと、Note that you can put comments in "data" as well as in "programs". というコメントのところで2行目の"data"が一文字字下げされています。 MITのMacLISPや、Lispマシンのコードでは良くみられるのですが、連続する場合は、塊が判別しやすくなるので見易くなるし良い作法だなと思っています。
;;;; COMMENT-EXAMPLE function.
;;; This function is useless except to demonstrate comments.
;;; (Actually, this example is much too cluttered with them.)

(defun comment-example (x y)      ;X is anything; Y is an a-list.
  (cond ((listp x) x)             ;If X is a list, use that.
        ;; X is now not a list.  There are two other cases.
        ((symbolp x)
         ;; Look up a symbol in the a-list.
         (cdr (assoc x y)))       ;Remember, (cdr nil) is nil.
        ;; Do this when all else fails:
        (t (cons x                ;Add x to a default list.
                 '((lisp t)       ;LISP is okay.
                   (fortran nil)  ;FORTRAN is not.
                   (pl/i -500)    ;Note that you can put comments in
                   (ada .001)     ; "data" as well as in "programs".
                   ;; COBOL??
                   (teco -1.0e9))))))

comments powered by Disqus