[swift-evolution] [Pitch] KeyPath based map, flatMap, filter

Benjamin Herzog mail at benchr.me
Sun Jul 16 11:34:27 CDT 2017

If it would be possible to make objects callable, wouldn't that also go
in the same direction as subscripts currently? One could also implement
it with the syntax for callable functions (in this case anonymous -
without a name). Instead of this:

subscript(index: Int) -> T

we could also write

func (_ index: Int) -> T

On the call side it would change from this:

list[3] to list(3)

I know that it's not necessary and not even better readable, but it goes
in the same direction in my opinion and is worth considering. What do
you think?


Benjamin Herzog

On Wed, Jul 12, 2017, at 10:21 PM, Dave Abrahams via swift-evolution
> 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 at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list