This appeared to work well (Julia 1.9.2), but when I moved my code to a local package and started using ] dev and Revise, I received alarming warning messages about this code (“incremental compilation fatally broken” and others). Then I realized that the above code should not work. The kwdef constructor is a zero-argument constructor with keywords, and therefore the outer zero-argument constructor should overwrite the kwdef constructor because Julia does not dispatch on keywords. And yet the above code seems to work well — both constructors are callable — except for the warning messages about incremental compilation. So I am wondering if the above code is correct. If it is correct, why is it causing warning messages from Revise?
I don’t have any insight to add about correctness, just wanted to make sure you’re aware that you can add default values directly in the @kwdef struct definition?
First, thanks to the previous poster for the reminder about default arguments. As for my original question, it appears I stumbled on an old open issue in Julia:
Despite the claim in the docs that multiple dispatch does not look at keyword arguments, it actually does in some circumstances. Maybe someone who understands this better than me could submit a PR to clarify the docs.