[swift-evolution] [swift-evolution-announce] [Review] SE-0111: Remove type system significance of function argument labels
Scott James Remnant
scott at netsplit.com
Thu Jun 30 15:30:28 CDT 2016
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?
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
>>
More information about the swift-evolution
mailing list