Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-13 Thread Douglas Gregor via swift-evolution
> On Dec 11, 2016, at 2:30 AM, Tommaso Piazza via swift-evolution > wrote: > > Hello Derrick, > > I did not think of this as a bug but rather as an intentional limitation that > to me seems a little odd. > > Yes, overloads 2,3 have at least ONE operand of type

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-13 Thread Tommaso Piazza via swift-evolution
Hi, I just wanted to revive this discussion and understand if this is a welcome change or not. Right now one can "fake" overload 1 inside NonEmptyArray by doing the following: ``` public struct NonEmptyArray {     private var elements: Array     private init(array: [Element]) {       

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-11 Thread Tommaso Piazza via swift-evolution
I cannot reply directly to this message  https://www.mail-archive.com/swift-evolution@swift.org/msg19099.html so I will reply here instead. I am suggesting that both behaviours should be allowed to co-exists (which is already the case, just there is this one exception.) No matter the

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-11 Thread Tommaso Piazza via swift-evolution
Thanks for the suggestion, I have updated the proposal with the error and with the notes on `fileprivate` -> `private` /Tommaso On Sunday, December 11, 2016 5:55 AM, Derrick Ho wrote: You may want to add the specific error to your proposal.   error: member

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-11 Thread Tino Heth via swift-evolution
imho the current behaviour is fine. I'll leave aside infix-operators, because with pre/postfix, the situation is simpler: It seems slightly confusing to me to declare such an operator somewhere else but at the type it works on. Afair the ability to declare an infix operator in a type

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-11 Thread Tommaso Piazza via swift-evolution
Hello Derrick, I did not think of this as a bug but rather as an intentional limitation that to me seems a little odd. Yes, overloads 2,3 have at least ONE operand of type NonEmptyArray so when declared as static function on NonEmptyArray they work fine. However Overload 1 just mentions

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-10 Thread Derrick Ho via swift-evolution
You may want to add the specific error to your proposal. *error: member operator '•|' must have at least one argument of type 'NonEmptyArray'* *public static func •|(lhs: Element, rhs: [Element]) -> NonEmptyArray* On Sat, Dec 10, 2016 at 11:49 PM Derrick Ho wrote:

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-10 Thread Derrick Ho via swift-evolution
I placed he code you wrote in the proposal in playgrounds and it works perfectly. (reproduced below). Overloading operators used to only happen globally and since swift 3 they allowed you to put then inside the class/struct public struct NonEmptyArray { fileprivate var elements: Array

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-10 Thread Robert Widmann via swift-evolution
I remember mentioning this in a meeting once. The old behavior (post 2.x-mid-operators-in-aggregates) did allow for this, the new one should too. ~Robert Widmann 2016/12/10 20:36、David Sweeris via swift-evolution のメッセージ: > >>> On Dec 10, 2016, at 5:29 PM, David

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-10 Thread David Sweeris via swift-evolution
> On Dec 10, 2016, at 5:29 PM, David Sweeris via swift-evolution > wrote: > >> >> On Dec 10, 2016, at 4:54 PM, Tommaso Piazza via swift-evolution >> > wrote: >> >> Hello, >> >> I have written a small

Re: [swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-10 Thread David Sweeris via swift-evolution
> On Dec 10, 2016, at 4:54 PM, Tommaso Piazza via swift-evolution > wrote: > > Hello, > > I have written a small proposal that would allow overloads of operators in > structs/classes non only based on the types of the operands but on the return > type as well. >

[swift-evolution] Proposal: Allows operator overloads in struct or classes based on return type

2016-12-10 Thread Tommaso Piazza via swift-evolution
Hello, I have written a small proposal that would allow overloads of operators in structs/classes non only based on the types of the operands but on the return type as well. Please let me know you thoughts,/Tommaso