Jimmy Hoffa
Jimmy Hoffa

Reputation: 5967

Clojure macro that doesn't need space next to it

Trying to create a macro form of Haskell's lambda syntax, I'm pretty close except one last tweak, the / (which should be a \, but can't grumble..) needs a space next to it, is there any way to make it so my macro doesn't need space between it and it's first argument?

for instance:

(reduce (/x y -> x y) [1 2 3])

instead of:

(reduce (/ x y -> x y) [1 2 3])

I suspect this isn't possible, but only way to know for sure is to ask people who know, so what's the word?

Upvotes: 2

Views: 132

Answers (2)

amalloy
amalloy

Reputation: 92067

No, but if you wanted to do something more ambitious, you could define another macro with-haskell-lambdas that you wrap your entire namespace in. That macro could look through all the forms under it, eg with tree-seq, find symbols of the form /x, and replace them with / x instead.

Upvotes: 2

Matthias Benkard
Matthias Benkard

Reputation: 15769

No. Macros cannot change the lexical syntax of the language. That requires read-macros, which Clojure doesn't have.

Upvotes: 5

Related Questions