julia icon indicating copy to clipboard operation
julia copied to clipboard

export Base.@kwdef

Open tk3369 opened this issue 6 years ago • 8 comments

The Base.@kwdef is such a useful feature. I cannot think of any reason why it should not be exported. Is there any concern doing that?

tk3369 avatar Sep 08 '19 00:09 tk3369

Come to think of it, another option is to support that syntax directly in the language without using any macro. Maybe that could be a 2.0 target?

tk3369 avatar Sep 15 '19 01:09 tk3369

I agree. This would be a nice feature for 1.6, since that will be the new Long-Term Support version.

CameronBieganek avatar Sep 03 '20 15:09 CameronBieganek

I had really always hoped that we'd get a better solution instead of baking @kwdef in as official 😞. At the very least it could have a better name.

StefanKarpinski avatar Sep 15 '20 19:09 StefanKarpinski

like supporting the syntax that @kwdef provides in structs? I guess all @kwdef about is having such a syntax? and it seems well adopted by the community already.

Roger-luo avatar Sep 15 '20 19:09 Roger-luo

any updates on this?

@logankilpatrick I think you tagged the wrong person.

CameronBieganek avatar Oct 18 '21 00:10 CameronBieganek

I would also love to see this as a stable feature

cocoa1231 avatar Oct 30 '21 16:10 cocoa1231

It's been almost a few years since this issue was opened. Any chance this could still happen? :)

czimm79 avatar Jul 20 '22 03:07 czimm79

From triage: yes we might as well export this. It's unfortunately too expensive to generate keyword constructors for every struct, and I don't see that changing without major changes to the language. We can however support default values for trailing fields in normal struct definitions, just like optional positional arguments. I suspect waiting for that feature (and wondering whether it is actually worthwhile) was part of what held up @kwdef.

JeffBezanson avatar Jul 21 '22 18:07 JeffBezanson