8000 Warn OptionalArgChecks.jl's scoping rule? · Issue #33 · jw3126/ArgCheck.jl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content 8000
Warn OptionalArgChecks.jl's scoping rule? #33
Open
@tkf

Description

@tkf

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.

cc @simeonschaub

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0