Lisp commenting convention

Viewed 52576

What is the Lisp convention about how many semicolons to use for different kinds of comments (and what the level of indentation for various numbers of semicolons should be)?

Also, is there any convention about when to use semicolon comments and when to use #|multiline comments|# (assuming they exist and exist on multiple implementations)?

5 Answers

It's annoying that people refer to conventions without explaining what's wrong with using double semicolons with end-of-line-comments.

There's nothing wrong per-se with using double semicolons with so called "margin" (end-of-line) comments. It may become a problem though if you want to have margin comments and regular comments in the same block, e.g.:

   (defn foo []
      (bar) ;; yup, bar
      ;; let's now do a zap
      (zap))

So, if you use fill-paragraph feature of Emacs - it will automatically align both those comments as if they were a single statement.

   (defn foo []
      (bar) ;; yup, bar
            ;; let's now do a zap
      (zap))

And that's not what you probably want. So if use a single semicolon instead:

   (defn foo []
      (bar) ; yup, bar
      ;; let's now do a zap
      (zap))

It will keep it as intended. So instead explaining this over and over again, I guess people just made a rule - use single semicolon for margin comments

Related