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

KeywordDispatch analogue to @kwdef #13

Closed
yygrechka opened this issue Jan 8, 2021 · 1 comment
Closed

KeywordDispatch analogue to @kwdef #13

yygrechka opened this issue Jan 8, 2021 · 1 comment

Comments

@yygrechka
Copy link

I'm relatively new to Julia, and I wanted keyword constructors, which led me to the Base.@kwdef macro

However, this macro does not allow keyword dispatch, which led me to this package.

With KeywordDispatch, I can do something like this:

struct Bar
    a::Int
    b::String
end

@kwdispatch Bar()

@kwmethod Bar(;a, b) = Bar(a,b)
@kwmethod Bar(;a) = Bar(a=a, b="1")

It would be useful to have an analogous macro to @kwdef that will automatically define this first constructor:

@kwmethod Bar(;a, b) = Bar(a,b)

If this is already implemented, I'd appreciate a pointer as to how this is done.

@yygrechka
Copy link
Author

yygrechka commented Jan 8, 2021

Accidental duplicate of:
#12

This issue should be deleted.

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

1 participant