Re: Feedback wanted: switch expression typing

2018-04-20 Thread Dan Smith
> On Mar 28, 2018, at 1:37 PM, Dan Smith wrote: > > At this point, we've got a choice: > A) Fully mimic the conditional behavior in switch expressions > B) Do target typing (when available) for all switch expressions, diverging > from conditionals > C) Do target typing (when available) for all s

Re: Feedback wanted: switch expression typing

2018-04-07 Thread Brian Goetz
-looking expressions. (Sorry, I can't recall examples.) > Having the same story for both of them would be best, assuming > that existing code doesn't break. > > -Doug > >> >> Rémi >> >> - Mail original - >>> De: "dan

Re: Feedback wanted: switch expression typing

2018-03-31 Thread Doug Lea
x27;t recall examples.) Having the same story for both of them would be best, assuming that existing code doesn't break. -Doug > > Rémi > > - Mail original - >> De: "daniel smith" >> À: "Remi Forax" >> Cc: "amber-spec-e

Re: Feedback wanted: switch expression typing

2018-03-31 Thread forax
De: "daniel smith" > À: "Remi Forax" > Cc: "amber-spec-experts" > Envoyé: Samedi 31 Mars 2018 03:44:49 > Objet: Re: Feedback wanted: switch expression typing >> On Mar 30, 2018, at 10:54 AM, Remi Forax wrote: >> >> I do not see (

Re: Feedback wanted: switch expression typing

2018-03-30 Thread Dan Smith
> On Mar 30, 2018, at 10:54 AM, Remi Forax wrote: > > I do not see (B) as sacrifying the consistency because the premise is that an > expression switch should be consistent with ?: > > But an expression switch can also be modeled as a classical switch that > returns it's value to a local varia

Re: Feedback wanted: switch expression typing

2018-03-30 Thread Remi Forax
I do not see (B) as sacrifying the consistency because the premise is that an expression switch should be consistent with ?: But an expression switch can also be modeled as a classical switch that returns it's value to a local variable. int a = switch(foo) { case 'a' -> 2; case 'b' ->

Re: Feedback wanted: switch expression typing

2018-03-29 Thread Brian Goetz
There’s a middle ground, which is: to pursue B now, in conjunction with trying to evolve the rules for conditionals over time by proceeding from warning to error. That gets us to a consistent and simpler place in the long run while mitigating the effect of a sudden inconsistent change. > On Ma

Re: Feedback wanted: switch expression typing

2018-03-29 Thread Liam Miller-Cushon
On Wed, Mar 28, 2018 at 3:55 PM Dan Smith wrote: > Subjectively, big picture: how concerned would you be about changing > typing rules in these cases? > My initial impression is that the compatibility impact of (C) would be manageable, especially with the change you mentioned to allow e.g. `Long

Re: Feedback wanted: switch expression typing

2018-03-28 Thread Tagir Valeev
Hello! Existing ?: behavior is certainly surprising and continuous source of puzzlers. E.g. the following was used in our latest Java Puzzlers NG S03 talk: boolean x = false; System.out.println(x ? 42 : null); // prints null System.out.println(x ? 42 : x ? 42 : null); // NPE It's really hard to

Re: Feedback wanted: switch expression typing

2018-03-28 Thread Dan Smith
> On Mar 28, 2018, at 4:17 PM, Liam Miller-Cushon wrote: > > Hi Dan, > > On Wed, Mar 28, 2018 at 12:38 PM Dan Smith > wrote: > If you're able to build OpenJDK with this patch and run it on some real-world > code, I'd appreciate any insights about what you find.