Description
IIUC, the effect of @skipargcheck
is dynamically scoped:
using OptionalArgChecks
@noinline f(x) = @argcheck x > 0
@noinline g(x) = f(x)
h(x) = @skipargcheck g(x)
h(-1) # no error
That is to say, @skipargcheck
is effective no matter how far away the function using @argcheck
is in the call chain. This is very different from @inbounds
as it works only with inlined calls (i.e., @inbounds
scoping is more-or-less lexical). On the other hand, there is no way for a callee to reliably throw an exception when using @argcheck
. I understand that exception is not used as "output" in Julia most of the time. However, you can find in some places exception type is crucial (e.g., NLsolve.jl, Optim.jl).
I do think OptionalArgChecks.jl is a very interesting approach to optional error handling. But, if my understanding of its scope is correct, I think it's better to have a warning on its scoping rule. Ideally, I think it's better to have a separate macro for enabling OptionalArgChecks.jl.