Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-26 Thread Mark Lacey via swift-evolution
> On May 25, 2016, at 11:37 PM, David Hart wrote: > > The former. This proposal is simply to make certain scenarios which require > to be explicit to be more elegant and more in line with generic types. > > Moreover, what you suggest might be dangerous. Imagine this code: >

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-26 Thread David Hart via swift-evolution
Sounds good :) I’ll mention those in the Alternatives. > On 26 May 2016, at 09:26, Callionica wrote: > > A perfectly reasonable preference. For me, "as" reads as a potential type > conversion (which I don't want) and specifying the type on the local can be >

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-26 Thread David Hart via swift-evolution
I personally don't really see the advantage of those deduction operators. I would prefer writing: let plus1: (Int, Int) -> Int = + let plus2 = + as ((Int, Int) -> Int) > On 26 May 2016, at 06:11, Callionica (Swift) > wrote: > > I have an alternative you might

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-26 Thread David Hart via swift-evolution
Yes, it matches the order of the generic parameters. I'll mention it explicitly in the next version. > On 26 May 2016, at 03:50, Patrick Smith wrote: > > Sounds good to me. So it matches the order of the generic parameters? > > e.g. > > func foo(t: T, u: U) { … } >

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-26 Thread David Hart via swift-evolution
The former. This proposal is simply to make certain scenarios which require to be explicit to be more elegant and more in line with generic types. Moreover, what you suggest might be dangerous. Imagine this code: func foo() -> (T, U) { ... } let a = foo() I just did a typo

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread Charlie Monroe via swift-evolution
+1. There are times where the compiler can't infer the type and gives weird errors (mostly due to inferring the type wrong). Making this explicit would help a lot. > On May 26, 2016, at 1:17 AM, David Hart via swift-evolution > wrote: > > Hello, > > This is a new

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread Callionica (Swift) via swift-evolution
I have an alternative you might like to consider: type deduction operators The input type deduction operator lets you put one or more types in front of a function to guide type deduction based on the parameters The output type deduction operator lets you put a type after a function to guide type

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread Austin Zheng via swift-evolution
I would like explicit specialization as well. For historical interest, there is a blurb in the generics design document describing the original rationale (https://github.com/apple/swift/blob/master/docs/Generics.rst , "Type

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread T.J. Usiyan via swift-evolution
+1 On Wed, May 25, 2016 at 7:50 PM, Patrick Smith via swift-evolution < swift-evolution@swift.org> wrote: > Sounds good to me. So it matches the order of the generic parameters? > > e.g. > > func foo(t: T, u: U) { … } > > let f1 = foo > > So if the function declaration was

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread David Sweeris via swift-evolution
On May 25, 2016, at 6:17 PM, David Hart via swift-evolution wrote: > > Hello, > > This is a new pitch to allow explicitly specializing generic functions. > Notice that potential ambiguity with initialisers and how I’m currently > trying to avoid it. Please let me

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread Patrick Smith via swift-evolution
Sounds good to me. So it matches the order of the generic parameters? e.g. func foo(t: T, u: U) { … } let f1 = foo So if the function declaration was changed to swap T and U, it would break, same as say a generic struct type. Patrick

Re: [swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread Mark Lacey via swift-evolution
> On May 25, 2016, at 4:17 PM, David Hart via swift-evolution > wrote: > > Hello, > > This is a new pitch to allow explicitly specializing generic functions. > Notice that potential ambiguity with initialisers and how I’m currently > trying to avoid it. Please let

[swift-evolution] [Pitch] Allow explicit specialization of generic functions

2016-05-25 Thread David Hart via swift-evolution
Hello, This is a new pitch to allow explicitly specializing generic functions. Notice that potential ambiguity with initialisers and how I’m currently trying to avoid it. Please let me know what you think! David Allow explicit specialization of generic functions Proposal: SE-