Infix math in Elisp

by Chris Barrett

This morning I awoke from a wicked dream where I was playing with Great White Shark pups. Attuned the oneness of all creation, I banged out a macro that lets me do this:

Oh God, why?

Glad you asked! Now that I’m getting comfortable with org-mode and calc, I sometimes want that newfangled infix math notation in my elisp. But using¬†calc-eval¬†feels so…stringy.

Hacky? Hell yes. But it’ll validate, eval and inline the expression’s result at macro-expansion time, which is cool. And it wouldn’t be too hard to relax those checks to allow variable interpolation.

Advertisements