Subject: Re: #+ and #-
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 16 Aug 2003 08:45:14 -0500
Newsgroups: comp.lang.lisp
Message-ID: <0IOcnYGa47z3qKOiXTWc-w@speakeasy.net>
Kenny Tilton  <ktilton@nyc.rr.com> wrote:
+---------------
| #-testing is "unless". The code gets included if 'testing is /not/ a 
| feature.
| 
| Normally one uses this to make development code code away for releases:
| 
|     #-production-release (worry-wart-validation)
| 
| And as you can see, it is a handy way to comment out multi-line forms:
| 
|     #+naahhhhh (print (list 'this-huge-expression
|                           'that-huge-expression))
+---------------

Just a reminder that we had a long thread a while back [pretty long ago,
actually, since Erik Naggum was a major contributor to the thread], in
which it was pointed out that the frequently-used #+NIL for "commenting-out"
code was technically unsafe, and #+NAAHHHHH is even more unsafe. How do
you know you won't someday load a hifty little package you got from the
"National Aerospace and Avionics Hardware Hackers and Handy Heap Helpers",
and suddenly find :NAAHHHHH on the features list??!?

Fortunately, as noted in that long-ago thread, there is an absolutely
safe alternative. The features syntax includes NOT/AND/OR expressions,
and those operators -- specifically AND and OR -- obey the "usual" Lisp
rules for null argument lists of the special forms ADN and OR. That is,
(AND) as a feature expression is *always* true, thus #+(AND) can always
be used to unconditionally enable code; likewise, #-(AND) can always be
used to unconditionally disable it.

So ever since then, I've been using *only* (AND) for those kinds of
things:

	#-(and) ;;XXX Turn this off for now.
	(print (list 'this-huge-expression
		     'that-huge-expression))
or:
	#+(and) ;;XXX Temporarily turn on for debugging.
	(format t ...)

Consistently using *only* (AND) with either #+ or #- has the advantage
that it's easier to remember what's enabled and disabled. Instead of
the inverted logic of #+NEVER-DEFINED to mean "off", you have #-(AND).
The minus is always used for "off", and the plus is always used for "on".
Simple. Easy.

[Thanks, Erik!]


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607