Skip to content(if available)orjump to list(if available)

When You Get to Be Smart Writing a Macro

kazinator

  #p x
is one character less than

  (p x)
When code golfing Lisps you can remove all whitespace after a closing paren, but not after a symbol. So in the following fully golfed token sequences, #p loses its one character advantage:

  #p x y
  (p x)y
I bring up code golfing because that's what this is about, presumably.

But what if the argument is a parenthesized expression:

  #p(x)
  (p(x))
#p is back in the game with a 1 char lead.

The thing is, we can make the printing operator take arguments and turn them into an expression. Suppose we make a cousin of p called q, such that:

  (q x) -> (p (x))

  (q x y z) -> (p (x y z))
q no longer loses to #p:

  (q x)
  #p(x)

null

[deleted]

EdwardDiego

Very smart. But also a good example of why macros are brittle.