> On Mar 15, 2016, at 5:01 PM, Brent Royal-Gordon <br...@architechies.com> 
> wrote:
> 
>       extension Foo {
>               static var readableProperties: [String: (inout Foo) -> inout 
> Any] = [
>                       "readWriteProperty": { $0.readWriteProperty },
>                       "readWriteNonmutatingProperty": { ... },
>                       "readOnlyProperty": { ... },
>                       "readOnlyMutatingProperty": { ... }
>               ]
>               static var writableProperties: [String: (inout Foo) -> inout 
> Any] = [
>                       "readWriteProperty": {
>                               get { return $0.readWriteProperty }
>                               set { $0.readWriteProperty = newValue as! Int }
>                       },
>                       "readWriteNonmutatingProperty": { ... }
>               ]
>       }

A mutable return has to be invariant. It'd be more sound to model that as 
"exists T. (inout Foo) -> inout T", if our type system becomes powerful enough 
to represent that, than to erase the return type, since you could then 
conceivably still recover the T by opening the existential. 

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

Reply via email to