[swift-evolution] [Proposal Idea] dot shorthand for instance members
Matthew Johnson
matthew at anandabits.com
Sat Dec 19 09:19:48 CST 2015
> On Dec 19, 2015, at 1:37 AM, Rob Mayoff via swift-evolution <swift-evolution at swift.org> wrote:
>
> When you access a static member of a type using the dot shortcut, Swift evaluates the expression immediately.
>
> Are you proposing that when you access a member of an instance, Swift generate a closure?
>
> Or are you proposing that Swift generate a closure or not depending on how the expression's value is to be used?
I was thinking of it more in terms of binding the non-self arguments, but either way is effectively the same. This would be necessary in all cases, although in the case of property getters and nullary methods there would no arguments to bind.
> Either way seems inconsistent with the static member situation, and like a potential source of confusion: not everyone uses the One True Convention™ of .Capitalized .Static .Members and .lowercase .instance .members, so one cannot reliably deduce the outcome based on the case of the character after the dot.
You can easily deduce it by the type context which you need to know to understand the code anyway. As capitalization is not enforced by the language it is not reasonable to deduce anything based on that.
If you think it could potentially be confusing that is a reasonable position.
>
> On Thu, Dec 17, 2015 at 9:27 PM, Matthew Johnson via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> anArray.map{$0.anInstanceMethod()}
>
> becomes:
>
> anArray.map(.anInstanceMethod())
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151219/6ea47140/attachment.html>
More information about the swift-evolution
mailing list