https://developer.apple.com/documentation/swift/double?changes=latest_minor
In updated version of class definition I found init method for Double with NSNumber near type the unknown keyword __shared
. What does it mean?
The __shared
parameter annotation means that a value type parameter can be passed by reference.
For value types, this enables us to elide a copy before we make the call and instead pass a reference pointing right at the memory we allocated. SIL calls this convention in_guaranteed
for (indirect reference with guaranteed lifetime). It's currently the way we pass self in non-mutating functions.
It was introduced by the Ownership Manifesto.
Here is the difference between the ownership annotations:
inout
: mutating pointer-like value__shared
: non-mutating pointer-like value__owned
: an explicit way of writing the defaultHere is a summary of the manifesto: Swift Ownership Manifesto TL;DR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With