Re: [swift-evolution] Evaluating the case of an enum with associated values as a bool

2018-01-02 Thread Ethan Diamond via swift-evolution
>>> In the past, we’ve discussed synthesizing predicate members onto enums. >>> E.g. given: >>> >>> enum E { >>> case X >>> case Y(Int) >>> } >>> >>> you’d get something like: >>> >>> exte

Re: [swift-evolution] Evaluating the case of an enum with associated values as a bool

2017-12-23 Thread Ethan Diamond via swift-evolution
> syntax (so far as I’m aware). You can’t negate the comparison to do >>>>>>> something for all cases except a particular case. You have to have an >>>>>>> empty if block and use the else block, or have an empty case in a >>>>>>>

Re: [swift-evolution] Evaluating the case of an enum with associated values as a bool

2017-12-21 Thread Ethan Diamond via swift-evolution
ussed synthesizing predicate members onto enums. > E.g. given: > > enum E { > case X > case Y(Int) > } > > you’d get something like: > > extension E { > func isX() -> Bool { return self == .X } > func getY() -> Int? { … } > } > > which w

Re: [swift-evolution] Evaluating the case of an enum with associated values as a bool

2017-12-20 Thread Ethan Diamond via swift-evolution
rs onto enums. >> E.g. given: >> >> enum E { >> case X >> case Y(Int) >> } >> >> you’d get something like: >> >> extension E { >> func isX() -> Bool { return self == .X } >> func getY() -> Int? { … } >> } >

Re: [swift-evolution] Evaluating the case of an enum with associated values as a bool

2017-12-20 Thread Ethan Diamond via swift-evolution
something like: > > extension E { > func isX() -> Bool { return self == .X } > func getY() -> Int? { … } > } > > which would solve the client side of this nicely. > > -Chris > > > > On Dec 20, 2017, at 11:24 AM, Ethan Diamond via swift-evolution < >

[swift-evolution] Evaluating the case of an enum with associated values as a bool

2017-12-20 Thread Ethan Diamond via swift-evolution
param) *>* default: *>* break *>* } *> >* I use this from time to time switching over, e.g., optional enums. *> >* *: ugliest syntax ever, and it can't even be used as a standalone expression. *> > >>* On Dec 20, 2017, at 8:44 AM, Ethan Diamond via swift

[swift-evolution] Evaluating the case of an enum with associated values as a bool

2017-12-20 Thread Ethan Diamond via swift-evolution
Hello everyone, One major pain point I've run into with Swift is the inability to evaluate the case of an enum that has associated values in a way that just returns a bool. We've been given the ability in a switch statement: enum Enum { case a(param: String) case b(param: String) } let enu

Re: [swift-evolution] Closure Syntax

2016-01-01 Thread Ethan Diamond via swift-evolution
still appreciate you taking the time to listen. -E On Thu, Dec 31, 2015 at 9:26 PM, Chris Lattner wrote: > On Dec 31, 2015, at 6:16 PM, Ethan Diamond via swift-evolution < > swift-evolution@swift.org> wrote: > > *There are three pieces at play here IMHO:* > *1. How func

Re: [swift-evolution] Closure Syntax

2015-12-31 Thread Ethan Diamond via swift-evolution
*There are three pieces at play here IMHO:* *1. How functions (global and on types) are declared and implemented* *2. How function specifications are indicated as types* *3. How anonymous functions are declared and implemented* Agreed, so lets flush out the rules a little more and see if we can fi

Re: [swift-evolution] Closure Syntax

2015-12-30 Thread Ethan Diamond via swift-evolution
d also have the same syntax everywhere, and be extremely similar to normal method calls which would be easier for new Swift users. -E On Tue, Dec 29, 2015 at 10:13 PM, David Waite wrote: > > On Dec 29, 2015, at 5:18 PM, Ethan Diamond via swift-evolution < > swift-evolution@swif

Re: [swift-evolution] Closure Syntax

2015-12-29 Thread Ethan Diamond via swift-evolution
statement in all cases. The compiler can make more assumptions about what it's parsing. I think it might limit what you have to work with to the compilers benefit. Thanks, - Ethan On Mon, Dec 28, 2015 at 5:44 PM, Chris Lattner wrote: > > On Dec 27, 2015, at 2:30 PM, Ethan Di

[swift-evolution] Closure Syntax

2015-12-28 Thread Ethan Diamond via swift-evolution
I realize this is on the commonly rejected list, but I really find closure syntax to be one of the more unintuitive and unreadable parts of Swift so I'd like to try to influence it. "Clarity at the point of use" is one of the main stated goals of Swift, and the fact that http://goshdarnclosuresynta