[swift-evolution] [swift-evolution-announce] [Review] SE-0111: Remove type system significance of function argument labels
Xiaodi Wu
xiaodi.wu at gmail.com
Thu Jun 30 15:40:39 CDT 2016
On Thu, Jun 30, 2016 at 3:30 PM, Scott James Remnant via swift-evolution <
swift-evolution at swift.org> wrote:
> As with the original proposal, your examples here don't obey the Naming
> Guidelines.
>
> If we're going to pretend that Swift is C, we wouldn't have a distinction
> between argument labels and parameter names in the first place!
>
> Is there an example of two functions, obeying the naming guidelines, which
> have different argument labels (not parameter names) for parameters of the
> same type, where it makes sense to cross-call them?
>
Sure there are. For example, `adding(_:)` and `multiplied(by:)` in the new
Integer protocol.
>
> Scott
>
> > On Jun 30, 2016, at 1:11 PM, Vladimir.S <svabox at gmail.com> wrote:
> >
> > On 30.06.2016 21:56, Scott James Remnant via swift-evolution wrote:
> >>> They already *are* type compatible. This works right now:
> >>>
> >>> var a : (ofHits: Int, forRuns: Int) -> Bool = meetsBattingAverage a =
> >>> sinkBattleship // ??? a(ofHits: 1, forRuns: 2)
> >>
> >> Your proposal does not make it clear that this works (which is
> >> surprising to me).
> >>
> >> I would argue the proposal the other way: that there should be an error
> >> on line 2, and this should not be permitted implicitly.
> >
> > I'm not sure if this is a definitely bad thing. Let's assume I have a
> number of funcs with similar but different labels and I want to define a
> function variable with another labels and assign one of these funcs:
> >
> > func foo(one: Int, two: Int) {..}
> > func bar(first: Int, second: Int) {..}
> >
> > var a : (alfa: Int, betta: Int) -> () = foo
> > a(alfa: 1, betta: 2)
> > a = bar
> > a(alfa: 1, betta: 2)
> >
> > But the type of `a` is still (Int, Int) -> () the same as for `foo` and
> `bar`
> >
> >>
> >> Scott _______________________________________________ swift-evolution
> >> mailing list swift-evolution at swift.org
> >> https://lists.swift.org/mailman/listinfo/swift-evolution
> >>
>
> _______________________________________________
> 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/20160630/d9ddc796/attachment.html>
More information about the swift-evolution
mailing list