Addition to Division Operator

For my own consistency, I would like
/ A * 100
to equal
A / 100.

I am not sure what you are asking for here, but it may not be possible, as / is parsed as a binary operator.

1 Like

There’s a binary and a unary form of - already, but I don’t know if it’d be worth the change or break something to introduce a unary /.

Even then, the semantics would probably not match the required one.

Since some form of AST transformation would be needed anyway, something like

using MacroTools

macro /(expr)
    @capture(expr, A_ * B_)
    :($A / $B)

julia> @/ 1 * 100

could be a starting point.

I don’t understand what you mean, for unary minus, we have

-a + b == b - a

so maybe you meant

/a * b == b / a

I guess you can use 1/a or inv(a)

1 Like

Oh I’m sorry, I read that as \ A * 100 should equal 100 \ A. Now I don’t know if this is what @vaeli intended, or if he really means it should be \ A * 100 == A \ 100, which looks kinda odd to me.

1 Like