[swift-evolution] [Probe] The automatically generated init for structs

Daniel Steinberg daniel at dimsumthinking.com
Fri Jul 1 06:09:47 CDT 2016

My apologies if this was resolved before. 

At one point there was a suggestion for the access level for the auto-generated init for structs. The issue was that the access level is internal by default. If you want to make this init public you have to implement the init yourself - there is no syntax for marking the default init as public.

Also, as in many other languages, if you implement your own init  the default init is not generated. There are times when you want this to be generated anyway so that other inits might call through it. Perhaps to set default values without having to reimplement this init.

Finally, in this last case you might want the default init generated but not exposed to the module or publicly - you may want to mark it as fileprivate but expose another init that uses it.

The following is horrible syntax but I wonder if there can be something that accomplishes these tasks - perhaps

@defaultInit  and

public @defaultInit

private @defaultInit



More information about the swift-evolution mailing list