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

Roadmap with respect to Base.@kwdef #89

Open
mauro3 opened this issue Nov 19, 2018 · 3 comments
Open

Roadmap with respect to Base.@kwdef #89

mauro3 opened this issue Nov 19, 2018 · 3 comments
Labels

Comments

@mauro3
Copy link
Owner

mauro3 commented Nov 19, 2018

Much of the @with_kw functionality has been implemented in Base.@kwdef, see JuliaLang/julia#29316, which will go into Julia 1.1. Once Julia 1.1 has been release, this should be used in Parameters. The plan could be to keep the @with_kw macro which would use @kwdef internally and enhance it with its "missing" features (show, reconstruct, type specific unpack macros, auto-documentation, @asserts).

@mauro3 mauro3 pinned this issue Jan 25, 2019
@mauro3
Copy link
Owner Author

mauro3 commented Feb 1, 2019

@kwdef only defines an outer constructor, whereas @with_kw defines both inner and outer. There seems to be a reason for that:

# NOTE: The reason to have both outer and inner keyword
, but I'm not sure this still applies.

@BeastyBlacksmith
Copy link

Maybe this relates:

I defined the following struct

@with_kw struct Vesicle{
                C<:Number, #Curvature
                AR<:Number, #Area
                VO<:Number, #Volume
                P<:Number, #Pressure
                T<:Number, #Tension
                L<:Number, #Length
                R<:Real,
                E<:Number, #Energy
              }
    m::C = zero(C)
    A::AR
    V::VO
    ΔP::P
    Σ::T
    u0::C
    u1::C
    S::L
    v::R
    κ::E = 8e-20u"J"
    function Vesicle(m::C, A::AR, V::VO, ΔP::P, Σ::T, u0::D, u1::D, S::L, v::R, κ::E) where {C,AR,VO,P,T,D,L,R,E}
        (mm, uu0,uu1) = promote(m,u0,u1)
        return new{typeof(mm),AR,VO,P,T,L,R,E}(mm, A, V, ΔP, Σ, uu0, uu1, S, v, κ)
    end # function
end # struct

but Vesicle(zeros(10)...) fails with a MethodError, while Base.@kwdef works fine.

@mauro3
Copy link
Owner Author

mauro3 commented Nov 23, 2019

A breaking change would probably be to fix #96 to be consistent with @kwdef. This would mean to deprecate the reconstruct-constructor (in favor of using Setfield.jl, probably).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants