Extend switch .. case statement for all types and simple expressions

Ulf Zibis Ulf.Zibis at gmx.de
Sun May 24 08:31:57 PDT 2009


Am 02.04.2009 11:34, Daniel Cheng schrieb:
> On Wed, Apr 1, 2009 at 5:17 PM, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
>   
>> I would like to add, that the MAJOR ADVANTAGE of my proposal is,
>> that the numerous grades/levels of this proposal could be implemented
>> step by step, depending on the complexity of changes, which could be
>> done for JDK 7.
>> More sophisticated grades/levels could be seamlessly added later.
>> This would be impossible, if the concurring syntax of "Strings in
>> switch", which only compares for equality, comes to account.
>> Also Multiple switch expressions and case ranges
>> <http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000213.html>
>> could seamlessly be integrated in my proposal.
>>
>> As I argued more detailed before, default semantic of "switch..case"
>> should stay on determining the cases by IDENTITY.
>> Strings, which are equal, could simply be made identical by String#intern().
>>     
>
> Except, using some combination of gc options, intern'ed String won't be gc'ed.
>
>   

Literals are always intern'd, so the wouldn't gc'ed either.

>> Example:
>>    switch (myStringFromElsewere.intern()) {
>>        case STRING1 : ...; // all constants are interned by definition
>>        case STRING2 : ...; //       "            "
>>        case "foo" : ...; // automatically interned
>>        case "bar" : ...; //       "            "
>>        ...
>>    }
>>
>> -Ulf
>>     
>
>
>   




More information about the coin-dev mailing list