10

Anybody know what #+ and #- operators means in .sbclrc? I couldn't find it in the manual. I see #- in .sbclrc after I installed quicklisp:

#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
                                       (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))

I also see #+ in the SBCL User Manual, but I couldn't find explanation of their functionality. Looks like something related for loading individual module.

Are they only for SBCL implementation or part of Common lisp?

Cactus
  • 27,075
  • 9
  • 69
  • 149
sudo
  • 647
  • 2
  • 7
  • 19

2 Answers2

21

That's a general facility of Common Lisp, not only SBCL.

There is a variable cl:*features* which lists symbols for 'features' which should be present in the Lisp system currently. Typical features are: endian, implementation, subsystems, processor, extensions, Lisp dialect and more.

In a Lisp file the expression #+quicklisp(foo) means: read and execute (foo) only if the feature quicklisp is present in the list of features *features*.

In a Lisp file the expression #-quicklisp(foo) means: read and execute (foo) only if the feature quicklisp is NOT present in the list of features *features*.

This facility is often used to hide or show implementation specific code to some other Common Lisp implementation.

See the documentation:

A typical extension is the feature-case reader macro.

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
8

They're part of the Common Lisp READer. The idea is that they "hide" text unless a certain feature (often, a certain CL implementation) is (#+) or is not (#-) available.

These are probably the CL concept most like the C/C++ idea of "textual macros" -- conceptually and pragmatically, they are very similar to something like

 #ifdef __MSVC12__
 #ifndef __cplusplus__

...and the like. They literally hide bits of incoming cource code from the READer, so they're never lexed - parsed - interpreted - compiled - evaluated - interned - nada. They simply cease to exist if the CL implementation you're running lacks a feature / is the "wrong" implementation / whatever flag.

Cactus
  • 27,075
  • 9
  • 69
  • 149
BRPocock
  • 13,638
  • 3
  • 31
  • 50
  • Do you know where I can find the documentation for this? I'm wondering if there is other READer features I don't know about. – sudo Dec 28 '11 at 05:09
  • 4
    In general, anything with a leading # is something special in the reader; check out the CLHS index under #, starting from http://www.lispworks.com/documentation/HyperSpec/Front/X_Mast_9.htm – BRPocock Dec 28 '11 at 05:25