Comment by dasyatidprime

4 days ago

Having skimmed the article, I think he's correct about the most common use of macros (by far the single most common type of macro I write in CL is a body-to-lambda transformation, though being able to tweak the sugar makes a difference too), but then I think he kinda equivocates in implications between “80% of the usage” and “80% of the impact”. I also think Ruby DSLs cover a big chunk of that last gap (and it sounds like you might agree with me). Part of the classic Lisp Curse is that easy access to advanced metaprogramming indirectly increases social fragmentation, but part of the Blub Curse is that lack of access to advanced features causes people to have to solve the same dumb problems over and over again, so you lose efficiency and create different fragmentation. Having fancier metaprogramming functionality require a bunch of rigamarole but be possible to work through when you need it might plausibly hit a sweet spot in the middle there.

Now that I've read through the Common Lisp HyperSpec and realized that there's no standard shortcut syntax for lambda, you have to spell it out every time (or define l as lambda), I'm realizing that yes, that is probably the most common use. I'm also starting to understand why Janet has the `short-fn` macro with special reader syntax for it: |(> $ 0) is short for (lambda (x) (> x 0)), which is SO much less typing. (It also handles multiple arguments: you can say |(> $0 $1) if for some reason you're allergic to just typing > to accomplish the same thing).

In fact, I think next time I'm writing Common Lisp code, I'm going to figure out how to create Janet's | as a reader macro.

  • FWIW, the common utility library Serapeum offers ‘op’ which it claims is from GOO, which is quite similar as a short positional function utility macro without being a reader macro that has more potential for character clashes: (op (> _ 0)). (But don't let that stop you from recreating it if you wanted to do so for educational purposes!)