> On Dec 22, 2015, at 1:36 PM, Guillaume Lessard <[email protected]> > wrote: > > (adding on) > >> On 22 déc. 2015, at 12:02, Matthew Johnson <[email protected]> wrote: >> >> Why would you have an immutable instance member that is always going to have >> a constant value of 1? > > That’s obviously a toy example. You can also use function calls, and that’s > useful: > > public struct A { > public let property = random() > } > > Would it make sense to allow a user in a different module write an extension > that subverts the `let` by assigning via a new initializer? > > extension A { > init(_ value: Int) { > self.property = value // ouch! > } > }
If the property is public then maybe it would if you interpret it as a default value, yes. It is possible to do this for var properties today. In any case, these rules won’t be changing. :) The discussion has convinced me that there is a useful distinction between the current behavior and a “default” value when it comes to `let` properties. _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
