News for hackers. Stuff that matters.
Re:Running Lisp in Production (2015) by reikonomusha on Sunday May 24, 2020 @02:09PM (#23293329)

    #+foo A B
This says if the Lisp supports “foo” as a “feature” (a precise term in Common Lisp), the A will be included. Otherwise A will be treated as a comment. B will be included regardless. It’s roughly equivalent to

    #ifdef foo
    A
    #endif
    B
The opposite is #-.

    #-unix A B
is roughly

    #ifndef unix 
    A
    #endif
    B
So you can write portable source code this way.

    (defvar path-separator
      #+unix "/"
      #+windows "\\"
      #-(or unix windows) (error "idk"))
This will define a variable called PATH-SEPARATOR which is / for UNIX, \ for Windows, and a compile-time error otherwise.

The rabbit hole goes deep on this. There’s a reason it uses ‘#’, and as you pointed out, it has to do with built-in (dispatching) reader macros.

There are no comments on this comment yet.