Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29787

Re: local constants with switch

From Mike Amling <mamling@chaff.us>
Newsgroups comp.lang.java.programmer
Subject Re: local constants with switch
Date 2014-08-21 13:19 -0500
Message-ID <c5mrg1F8ls0U1@mid.individual.net> (permalink)
References (1 earlier) <0d3ba8f9-586e-428f-9982-15b4c4da4690@googlegroups.com> <slrnlut96n.fp3.avl@login.logic.tuwien.ac.at> <tlr5v9dbqdlbi0pqo43pnapptb8akcroe3@4ax.com> <slrnlvbume.fp3.avl@login.logic.tuwien.ac.at> <rbtwwg9my3or.ismdzx8ghbbp$.dlg@40tude.net>

Show all headers | View raw


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==

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-12 16:56 +0000
  Re: local constants with switch Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-08-12 20:30 +0300
  Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-12 21:15 +0000
    Re: local constants with switch Silvio <silvio@internet.com> - 2014-08-12 23:20 +0200
    Re: local constants with switch Silvio <silvio@internet.com> - 2014-08-12 23:22 +0200
  Re: local constants with switch Lew <lewbloch@gmail.com> - 2014-08-15 15:22 -0700
    Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-16 00:24 +0000
      Re: local constants with switch Roedy Green <see_website@mindprod.com.invalid> - 2014-08-18 23:46 -0700
        Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-21 13:57 +0000
          Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-21 18:52 +0200
            Re: local constants with switch Mike Amling <mamling@chaff.us> - 2014-08-21 13:19 -0500
              Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-21 22:41 +0200
            [OT] Re: local constants with switch Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-21 14:42 -0400
              Re: [OT] Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-21 19:21 +0000
                Re: [OT] Re: local constants with switch Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-08-21 22:30 -0500
                Re: [OT] Re: local constants with switch Silvio <silvio@internet.com> - 2014-08-23 14:01 +0200
                Re: [OT] Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 15:22 +0000
              Re: [OT] Re: local constants with switch Arne VajhĂžj <arne@vajhoej.dk> - 2014-08-23 22:12 -0400
          Re: local constants with switch Jim Gibson <jimsgibson@gmail.com> - 2014-08-21 17:04 -0700
            [OT] Re: local constants with switch Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-21 20:50 -0400
              Re: [OT] Re: local constants with switch Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-22 11:48 +0000
  Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-16 01:18 +0200
    Re: local constants with switch Arne VajhĂžj <arne@vajhoej.dk> - 2014-08-15 22:44 -0400
      Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-16 09:01 +0000
        Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-16 12:08 +0200
        Re: local constants with switch Arne VajhĂžj <arne@vajhoej.dk> - 2014-08-16 20:39 -0400
          Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-17 13:08 +0200
      Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-16 12:07 +0200
  Re: local constants with switch Arne VajhĂžj <arne@vajhoej.dk> - 2014-08-15 22:42 -0400
    Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-16 09:17 +0000

csiph-web