> On Jan 25, 2017, at 10:20 AM, Edward Connell via swift-users 
> <swift-users@swift.org> wrote:
> 
> I have a data structure that calls isKnownUniquelyReferenced on a member. It 
> forces everything to be marked as mutating because of the inout parameter, 
> however the parameter is never mutated, it is just read right?? The reason it 
> is inout is because a read only reference is required.
> 
> If it is truly not mutating, is there some way around this so I don't have to 
> mark everything in the caller chain as mutating also? It's kind of annoying...

In Swift's current model, `isKnownUniquelyReferenced` needs to be inout because 
that's currently the only way to assert unique access to an object in memory, 
since read-only rvalues are otherwise freely copyable so the result of the 
uniqueness check would be only momentarily valid at best. What are you trying 
to do that requires using it on a nonmutable value? There may be another way to 
go about it.

-Joe

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to