jolin-io / NotMacro.jl

use `@not` instead of `!`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NotMacro

Build Status Coverage

NotMacro exports @not which can be used instead of the negation operator ! to make code easier to read. The syntax is borrowed from Python and will feel much more intuitive for Python users.

There is no performance penalty when using @not, it just compiles to plain !.

julia> using NotMacro

julia> if @not isodd(2) && @not iseven(3) && true
           println("works")
       end
works

julia> @macroexpand if @not isodd(2) & @not iseven(3) & true
           println("works")
       end
:(if !(isodd(2)) & (!(iseven(3)) & true)
      #= none:2 =#
      println("works")
  end)

About

use `@not` instead of `!`

License:MIT License


Languages

Language:Julia 100.0%