Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Mike Amling Newsgroups: comp.lang.java.programmer Subject: Re: local constants with switch Date: Thu, 21 Aug 2014 13:19:04 -0500 Lines: 34 Message-ID: References: <0d3ba8f9-586e-428f-9982-15b4c4da4690@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net eRrnLq2wOeC/aW4nHQVPFQiMGSRj7M6XyZOm5YY+Bqti6iwSGJ Cancel-Lock: sha1:PxsKAlWVELc2xRLDFPSIyJZzb7g= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:29787 On 8/21/14 11:52 AM, Joerg Meier wrote: > On Thu, 21 Aug 2014 13:57:33 +0000 (UTC), Andreas Leitgeb wrote: >> If a dependent "constant variable" >> ends up before what it depends on, then you'd get: >> " ... error: illegal forward reference > > Not neccessarily: > > private static final int i = 1; > private static final int blub = i++; > private static final int bla = i++; > > Accidentally let your code formatter sort fields and you get a bug without > an error or exception. Though obviously this would be bad design in the > first place. I can't tell what point you're making. Your code sample fails when it tries to ++ a final int. But even if the "final" modifier is removed from i, the compiler won't regard blub and bla as compile-time constants (hence won't allow them as case labels, e.g.). Yet your text seems to be talking about how the values blub=1 bla=2 are reversed if the formatter alphabetizes the order in which blub and bla are declared. > >> PS: I agree, that "constant variable" is an oxymoron. >> A better term might have been "(constant) vari-un-able" ;-) > > Good old C went with just "constant", if I recall. --Mike Amling VGhlIGFuY2llbnQgR3JlZWtzIGRpZCBub3QgY29uc2lkZXIgdGhlbXNlbHZlcyBhbmNpZW50Lg==