> On 12. Jul 2017, at 22:21, Dave Abrahams via swift-evolution
> <swift-evolution@swift.org> wrote:
>
>
> on Tue Jul 11 2017, Robert Bennett <rltbennett-AT-icloud.com> wrote:
>
>> Just realized that even inout functions don’t let you do
>> member(object) = value.
>
> The other difference is that an inout function can't be used to get a
> member from an immutable value, whereas a keypath/subscript/property
> access can.
>
>
> --
> -Dave
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
Hmm… I forgot about setters.
I would still like some simple way to use a KeyPath where an equivalent closure
would be expected (for getters AND setters). The operator approach looks like
the best one, but I’d prefer a prefix operator, so…
\MyObj.something.name // returns KeyPath<MyObj, String>
^\MyObj.something.name // returns (MyObj)->String
^myKeyPath // as above.
*\MyObj.something.name // returns (inout MyObj, String)->Void
*myKeyPath // as above.
Where those operators could, either now or later, be backed by some kind of
protocol (similar to Equatable/Comparable) to express general-purpose callable
objects.
But I don’t like how cryptic it all looks.
- Karl
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution