operator #+ and #- in .sbclrc

久未见 提交于 2019-11-28 13:26:22

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.

BRPocock

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!