Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wishlist: allow @argcheck instead of @assert #34

Closed
tpapp opened this issue Jul 24, 2017 · 3 comments
Closed

wishlist: allow @argcheck instead of @assert #34

tpapp opened this issue Jul 24, 2017 · 3 comments

Comments

@tpapp
Copy link
Contributor

tpapp commented Jul 24, 2017

Parameters.jl and ArgCheck.jl are two staple packages I always use for code. I like how @argcheck allows more meaningful error messages. I wonder if @with_kw could also collect @argcheck forms into the constructor, in addition to @assert.

@mauro3
Copy link
Owner

mauro3 commented Aug 2, 2017

Yes, that should be fine. I don't use ArgCheck.jl myself, but PR is welcome.

@mauro3
Copy link
Owner

mauro3 commented Jan 17, 2018

There seems to be something brewing with @assert: JuliaLang/julia#25576 (comment)

@singularitti
Copy link
Contributor

singularitti commented Jul 3, 2020

The reason that blocks to insert @argcheck is that @argcheck will be expanded to a begin block that is forbidden by with_kw.

julia> @macroexpand @argcheck 2 > 1
quote
    $(Expr(:meta, :begin_optional, ArgCheck.LabelArgCheck()))
    begin
        var"#130###302" = (>)
        var"#131###303" = 2
        var"#132###304" = 1
        if var"#130###302"(var"#131###303", var"#132###304")
            ArgCheck.nothing
        else
            ArgCheck.throw(ArgCheck.build_error(ArgCheck.CallErrorInfo($(QuoteNode(:(2 > 1))), ArgCheck.ArgCheckFlavor(), $(QuoteNode(Any[:>, 2, 1])), [var"#130###302", var"#131###303", var"#132###304"], ())))
        end
    end
    $(Expr(:meta, :end_optional, ArgCheck.LabelArgCheck()))
end

@mauro3 mauro3 closed this as completed in 501b47b Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants