In the ArgCheck package, there is the @argcheck
macro that can be used to check function arguments:
julia> using ArgCheck
julia> f(x) = (@argcheck x >= 0; x)
f (generic function with 1 method)
julia> f(1)
1
julia> f(-1)
ERROR: ArgumentError: x >= 0 must hold. Got
x => -1
0 => 0
However in performance critical code you may not want the branch that is introduced by @argcheck
.
This is similar to the situation with boundschecks. Now in the case of boundschecks there is the @inbounds
macro. It would be nice to have an analogous @noargcheck
to suppress @argcheck
. Is it possible to implement such a thing in a package?