;;;; NEPTUNE LANDING CODE
;;;; Copyright NASA, 2006.
;;;; [Some years ago, the first ;;;; line might
;;;; contain info read by the Lisp system and/or
;;;; editor.]
;;; Main section: my-func
#| This implementation is terrible! Forget it.
(defun my-func ()
(my-input)
(main-work-from-barney)) ;; rotten O(n^2) algorithm
|#
(defun my-func ()
(my-input) ; singles often get tabbed over
(main-work)) ;; great O(n log n) version from Dora
;;;; NEPTUNE LANDING CODE
;;;; Copyright NASA, 2006.
;;;; [Some years ago, the first ;;;; line might
;;;; contain info read by the Lisp system and/or
;;;; editor.]
;;; Main section: my-func
#| This implementation is terrible! Forget it.
(defun my-func ()
(my-input)
(main-work-from-barney)) ;; rotten O(n^2) algorithm
|#
(defun my-func ()
(my-input) ; singles often get tabbed over
(main-work)) ;; great O(n log n) version from Dora
Jonathon McKitrick wrote:
> what's the difference between ';' comments
> and '#|...|#' comments?
You probably know this, but keep in mind there are also ways to
"comment" things out like:
(list 1
#-(and) (+ 999 999)
2)
-> (1 2)
(list 1
#-(and) #-(and) :absurd-keyword (+ 999 999)
2)
-> (1 2)
Tayssir
> Silly question: what's the difference between ';' comments and '#|...|#' comments?
The obvious answer is that one goes from semicolon to newline, the
other from hash pipe to pipe hash. :)
A subtle difference is that # is a non-terminating macro character
whereas ; is terminating. Therefore:
A;this is symbol followed by a comment
A#|this is whole thing is a symbol|#
Because # is a dispatching macro character, it's syntactically possible
to have digits there also, but this is an error:
#1234| what? |#
Not clear to me whether this requires an error to be signaled, or is
undefined behavior.
The #| |# comments nest. But the inner nested occurences are recognized
without regard for the language syntax. That is to say, everything
between #| and |# is just characters to be ignored, but every embedded
#| digraph must be matched by |#.
E.g.
#| (X Y #| "STRING|#" Z) |#
The material between the outermost #| |# only resembles the regular
Lisp syntax; it isn't taken to be such.
The important difference is in how they're expected to be used.
';' is generally used for textual comments, while '#|...|#' is normally
used for commenting out sections of code. This is because #|...|# can
easily be inserted into the code without affecting anything around it.
For instance, if you have:
(defun sample-func (arg)
(do-this arg)
(do-another arg)
(do-one-more-thing arg))
you can easily comment out the last line:
(defun sample-func (arg)
(do-this arg)
(do-another arg)
#|(do-one-more-thing arg)|#)
If you wanted to use ';' you would have to move the final parenthesis to
the next line, to keep it from being commented out as well.
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Stefan Scholl
Subject: Re: Silly question: what's the difference between ';' comments and '#|...|#' comments? N.P.
Date:
Message-ID: <0T3cff6eIn51Nv8%stesch@parsec.no-spoon.de>
Like // and /* ... */ in the C like languages.
--
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/
Stefan Scholl wrote:
> Like // and /* ... */ in the C like languages.
But note that /* in C and C++ is scanned only to find a */ sequence to
terminate the comment, so these comments do not nest.