gohanlon / swift-memberwise-init-macro

Swift Macro for enhanced automatic inits.
MIT License
122 stars 8 forks source link

Always default `optionalsDefaultNil` to `false`, despite Swift 5 #7

Open gohanlon opened 1 year ago

gohanlon commented 1 year ago

Description

Swift provides non-public initializers that default optionals to nil. A design tenet of MemberwiseInit has been to strive to be a pure superset of Swift's memberwise initializer, and this approach has largely served it well.

However, I'm convinced that MemberwiseInit should deviate from Swift 5 and always default _optionalsDefaultNil to false, regardless of access level.

Swift's behavior is:

MemberwiseInit can offer a more straightforward approach: Optionals should not default to nil unless explicitly specified by the developer.

This has been debated at length on the forums: