switch with several arguments

Remi Forax forax at univ-mlv.fr
Wed Dec 13 14:45:44 UTC 2017

Technically, you do not need tuples/value types because you push the value,
matching on several arguments is already something that need to be supported when destructuring  because you need to match all the arguments of the result of a call to the destructor.

Anyway , at least, we have to check that the meta protocol will allow such extension.

I'm typing this in the movie theater waiting for last star wars, if you do not agree, I will tell you how it's ends.

On December 13, 2017 2:43:00 PM GMT+01:00, Gavin Bierman <gavin.bierman at oracle.com> wrote:
>You’ll not be surprised to hear that we’ve thought about it. It is
>certainly a very cool extension and makes for some very slick code.
>Personally I think it should wait until we have thought about tuples
>more generally (which might well be part of a value types enhancement).
>> On 13 Dec 2017, at 10:25, Remi Forax <forax at univ-mlv.fr> wrote:
>> Should we support a switch with several arguments ?
>> By example:
>>  for(int i = 1; i < 100; i++) {
>>    System.out.println(
>>      switch(i % 3, i % 5) {
>>        case (0, 0) -> "FizzBuzz";
>>        case (0, _) -> "Fizz";
>>        case (_, 0) -> "Buzz";
>>        default -> i;
>>      });
>>  }
>> Apart FizzBuzz, it's very convenient when you want to merge things,
>take decision depending on more than one value.
>> Note that this example also use the "locals do not need to be
>effectively final" semantics.
>> Rémi

Sent from my Android device with K-9 Mail. Please excuse my brevity.

More information about the amber-spec-observers mailing list