[swift-evolution] Allowing mutable members in structs

Charles Constant charles at charlesism.com
Sat Mar 12 07:10:35 CST 2016

... just to clarify my last comment.

Maybe "array.first" and "array.last" is a bad example, since it was
probably a design choice to make them "read only"

Here's a contrived example of what sometimes irritates me:

*struct Foo {*
* var point =  CGPoint( x:0, y:0 )*
* var prop: CGPoint {*
* return self.point*
* }*

*var foo = Foo()*

*foo.prop.x = 10 // illegal*

When I'm writing something like this, it does make me wish I could tell the
compiler to send "prop" by reference. If I'm just creating the getter as a
convenience to find the correct property (like .first) it's a bit of a drag
to fill out the setter side also.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160312/3fda8813/attachment.html>

More information about the swift-evolution mailing list