Inside the macro, is it possible to evaluate var to empty / nothing?

Thanks to previous answers on common lisp: how can a macro define other methods / macros with programmatically generated names? I have a macro that defines helper functions (actually I have a macro, my new favorite lisp is a new hammer). But there is something inside this macro that decides whether helper functions are needed in a particular argument. Thus, I have an if statement with almost identical branches - one branch at a time, I put, var in the list of lambda generated functions. Down another branch, I omit var. (I write DSL for non-programmers, so I don’t want them to see things like & optional)

Is there a way to avoid code duplication here? If I set var to ", then" "appears in the lambda list of my generated defuns. If I set var to nil, then NIL appears instead.

Is there a value that I can use so that var has absolutely no meaning at all, blinking from existence? (And philosophical interest, shouldn't there be one?)

+3
source share
1 answer

One option is to use ,@varand make a difference if it should be used nil, if it should not. For instance:

(let ((used `((frob 1 2 3)))
      (unused nil))
  `(progn ,@unused ,@used))
=> (PROGN (FROB 1 2 3))

The meaning is unusedgone.

+5
source

All Articles