[swift-evolution] [Proposal Idea] dot shorthand for instance members

Matthew Johnson matthew at anandabits.com
Thu Dec 17 21:27:39 CST 2015

Swift currently offers dot shorthand for static members of type Self in type contexts expecting a value of the type in question.  This is most commonly used with enum cases.

Swift does not currently offer shorthand for instance members.  Introducing a shorthand for instance members would improve clarity and readability of code in common cases:




This shorthand would work in typing contexts expecting a single argument function.  It would allow abbreviated access to any visible instance property getter or instance method on the type of the argument.  Of course the return type would need to match the return type expected by the context or a type mismatch compiler error would occur.

The readability advantage is arguably small but it does exist.  The feature also aligns very well with an existing language feature.

I think it’s an interesting idea and am wondering whether others feel like it is something worth pursuing or not.


More information about the swift-evolution mailing list