[swift-evolution] [Proposal Draft] Flexible memberwise initialization

Tino Heth 2th at gmx.de
Wed Dec 23 05:27:35 CST 2015


> Why would you have an immutable instance member that is always going to have a constant value of 1?  That just wastes space by duplicating the constant value in many instances.  However it is quite reasonable to have an immutable instance member that defaults to 1, but may have a different value depending on the initializer that is used for the instance.
All true:
"let n = 1" is useless, and it would be useful to take this as a hint for the generated initializer… but it would break the rules for let.

Afair, in an older version of Swift, you could change the value of constants in init (I think it was changed when delayed assignment for constants was introduced).
Is this false memory, or does anyone know about the motivation for that change?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151223/3c996e42/attachment.html>


More information about the swift-evolution mailing list