> On Feb 20, 2017, at 10:42 AM, Charles Srstka via swift-evolution
> <[email protected]> wrote:
>
>> On Feb 20, 2017, at 10:55 AM, Michel Fortin via swift-evolution
>> <[email protected] <mailto:[email protected]>> wrote:
>>
>> a) Structs/Locals:
>> Structs and local variables behave similarly. You can access `let` and `var`
>> properties and mutate the later.
>
> What if the struct contains class ivars, including private ones that you may
> not know about but nonetheless get accessed as a side effect of accessing the
> struct’s “var” properties?
>
>> b) Classes:
>> You can't access the variables of a class in a pure function. But you can
>> access its `let` properties. That's because as long as there is no `var` in
>> the dereferencing path, you are guarantied to be accessing a constant. In
>> classes, `let` properties are thus implicitly pure; stored `var` properties
>> are not. Which means that pure instance methods on classes can only access
>> `let` properties, in addition to computed properties that are themselves
>> `pure` and other `pure` methods.
>
> What if the “let” property becomes a “var” property in a future version of
> the library you’re linking against?
I think that’d be considered a breaking change anyway, since “let” means
“immutable” whereas vars with inaccessible setters merely can’t be mutated by
clients.
- Dave Sweeris
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution