Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6030335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:01:19+00:00 2026-05-23T05:01:19+00:00

What is the Lisp convention about how many semicolons to use for different kinds

  • 0

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)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:01:19+00:00Added an answer on May 23, 2026 at 5:01 am

    In Common Lisp:

    ;;;; At the top of source files
    
    ;;; Comments at the beginning of the line
    
    (defun test (a &optional b)
      ;; Commends indented along with code
      (do-something a)                      ; Comments indented at column 40, or the last
      (do-something-else b))                ; column + 1 space if line exceeds 38 columns
    

    Note: Emacs doesn’t fontify #| |# very well, but as Rainer suggests in the comments, try using #|| ||# instead.

    I’d say there are no rules to use this one, but I reckon it’s faster for commenting huge amounts of code, or to insert some long description where the semicolons just get in the way of editing, like huge BNF listings or the like.

    There’s a neat trick to disable code which is to prefix an expression with #+(or):

    (defun test (a &optional b)
      #+(or)
      (do-something a)
      (do-something-else b))
    

    Note: #+nil usually works too, unless you happen to have a nil or :nil feature. The advantage of #+(or) is that you can edit it easily by either commenting it out or change it to #+(and), or to actually include a set of features upon which you really want that expression to be read.

    SLIME helps here by fontifying the form (do-something a) as a comment when you have a Lisp running.

    Apart from Common Lisp’s particular commenting syntax and tricks, such as #| |# and #+(or) or the more commonly seen #+nil, I believe the semicolon rules are widely adopted in other lisps too.


    Here’s an excerpt from the specification, note how current practice has diverged regarding the single semicolon:

    2.4.4.2 Notes about Style for Semicolon

    Some text editors make assumptions about desired indentation based on the number of semicolons that begin a comment. The following style conventions are common, although not by any means universal.

    2.4.4.2.1 Use of Single Semicolon

    Comments that begin with a single semicolon are all aligned to the same column at the right (sometimes called the “comment column”). The text of such a comment generally applies only to the line on which it appears. Occasionally two or three contain a single sentence together; this is sometimes indicated by indenting all but the first with an additional space (after the semicolon).

    2.4.4.2.2 Use of Double Semicolon

    Comments that begin with a double semicolon are all aligned to the same level of indentation as a form would be at that same position in the code. The text of such a comment usually describes the state of the program at the point where the comment occurs, the code which follows the comment, or both.

    2.4.4.2.3 Use of Triple Semicolon

    Comments that begin with a triple semicolon are all aligned to the left margin. Usually they are used prior to a definition or set of definitions, rather than within a definition.

    2.4.4.2.4 Use of Quadruple Semicolon

    Comments that begin with a quadruple semicolon are all aligned to the left margin, and generally contain only a short piece of text that serve as a title for the code which follows, and might be used in the header or footer of a program that prepares code for presentation as a hardcopy document.

    2.4.4.2.5 Examples of Style for Semicolon

    ;;;; Math Utilities
    
    ;;; FIB computes the the Fibonacci function in the traditional
    ;;; recursive way.
    
    (defun fib (n)
      (check-type n integer)
      ;; At this point we're sure we have an integer argument.
      ;; Now we can get down to some serious computation.
      (cond ((< n 0)
             ;; Hey, this is just supposed to be a simple example.
             ;; Did you really expect me to handle the general case?
             (error "FIB got ~D as an argument." n))
            ((< n 2) n)             ;fib[0]=0 and fib[1]=1
            ;; The cheap cases didn't work.
            ;; Nothing more to do but recurse.
            (t (+ (fib (- n 1))     ;The traditional formula
                  (fib (- n 2)))))) ; is fib[n-1]+fib[n-2].
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As a non-lisper coming to clojure how should I best understand the naming convention
When editing Lisp code, occasionally it's useful to entirely comment out a top-level definition,
many (may be all?) programming language consist of assembly language how lisp implemented in
What lisp config command would bind this command, if it's not already bound? Also,
After reading Practical Common Lisp I finally understood what the big deal about macros
Does any Common Lisp (builtin) function return more than 2 values? I know many
Common Lisp macros typically use included-prefix notation: (operator stuff...) However, the special quote macro
I'm learning emacs lisp and I'm trying to script using it. I wrote a
With Clojure (and other Lisp dialects) you can modify running code. So, when a
I have some lisp initialisation code: (eval-when (:compile-toplevel :load-toplevel :execute) (require 'asdf)) (eval-when (:compile-toplevel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.