rm-hull / infix

A Clojure library for expressing LISP expressions as infix rather than prefix notation
https://www.destructuring-bind.org/infix/
MIT License
107 stars 12 forks source link

Drop selected aliases? #6

Closed eivindw closed 8 years ago

eivindw commented 8 years ago

In my code I had a value named e. In the expression this was translated to Math/E:

user=> (macroexpand-1 '(infix e * 2))
(* Math/E 2)

Is there any way I could exclude e from being aliased? I could of course change my code, but the original expression description uses the name e so I would rather keep it if I can..

What I wish for is a way I could make it keep e as the value:

user=> (macroexpand-1 '(infix e * 2))
(* e 2)
eivindw commented 8 years ago

Alternatively; is there a way to only use the "Basic ops"? Maybe a separate macro only using basic ops or something could be made? The expressions I need to solve typically look like this: (infix a - b + 2 * e - f - 114) So I don't really need the aliases at all..

rm-hull commented 8 years ago

You could try:

(with-redefs [infix.macros/operator-aliases nil]
  (infix e * 2))

I'll have a think about a more satisfactory longer term solution

rm-hull commented 8 years ago

If you add a call to (infix.core/suppress! 'e) somewhere before the macro call, then e won't be aliased to Math/E anymore:

user=> (macroexpand-1 '(infix e * 2))
(* e 2)