> On Feb 17, 2017, at 7:37 AM, David Hart <da...@hartbit.com> wrote:
> 
> On 17 Feb 2017, at 08:59, Nicolas Fezans via swift-evolution 
> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
> 
>> > Not only that, but even if you pass a value type as a parameter, that 
>> > value type might have reference types as ivars.
>> 
>> I think that arguments passed to a pure function shall be checked against 
>> containing such references or objects that contains such references 
>> themselves: I guess that this check could be made by the compiler.
>> Programmers will then have to see whether they choose a) to go to "pure 
>> value-type arguments" (i.e. not containing directly nor indirectly such 
>> references) and be able to declare some of their functions as pure or b) to 
>> keep these references and not declare the corresponding functions as pure.
> 
> Wouldn't we need a way to declare value semantics? Array has such references 
> but has value semantics so should be fine, no?

Arrays can contain reference types. If you have an array of references, you can 
call a mutating function on one of them…

There’s also the other built-in value types that are backed by reference types: 
URL is backed by NSURL, Data is backed by NSData. They won’t mutate, because 
they’re set up to make sure they get immutable versions of them, but how is the 
compiler going to prove it?

Charles

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

Reply via email to