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


Groups > comp.lang.java.programmer > #29642 > unrolled thread

local constants with switch

Started byAndreas Leitgeb <avl@auth.logic.tuwien.ac.at>
First post2014-08-12 16:56 +0000
Last post2014-08-16 09:17 +0000
Articles 20 on this page of 30 — 12 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  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

Page 1 of 2  [1] 2  Next page →


#29642 — local constants with switch

FromAndreas Leitgeb <avl@auth.logic.tuwien.ac.at>
Date2014-08-12 16:56 +0000
Subjectlocal constants with switch
Message-ID<slrnlukhpi.fp3.avl@login.logic.tuwien.ac.at>
It never before occurred to me, that one could define a local constant
within a method (e.g.: final int foo = 42;) AND use it for a case label
in a switch statement.

I'm a bit curious about whether this is an old-age feature that I've
been missing out for a very long time, or if this just came in recently...

I had a look at the JLS, too: the description of switch(§14.11) refers to
term constant expression (§15.28), which further refers to constant
variables (§4.12.4), which is about final variables generally.

From that it wouldn't even be necessary for that variable to be itself
initialized with a constant expression, but I probably just missed that
wording, because it (expectably) doesn't work with a final whose initial
value is not a constant expression itself, nor with a final variable
that isn't immediately initialized.

[toc] | [next] | [standalone]


#29644

FromDonkey Hottie <donkey@fredriksson.dy.fi>
Date2014-08-12 20:30 +0300
Message-ID<ejvpbb-g5s.ln1@tempest.fredriksson.dy.fi>
In reply to#29642
12.08.2014, 19:56, Andreas Leitgeb kirjoitti:
> It never before occurred to me, that one could define a local constant
> within a method (e.g.: final int foo = 42;) AND use it for a case label
> in a switch statement.
> 
> I'm a bit curious about whether this is an old-age feature that I've
> been missing out for a very long time, or if this just came in recently...
> 
> I had a look at the JLS, too: the description of switch(§14.11) refers to
> term constant expression (§15.28), which further refers to constant
> variables (§4.12.4), which is about final variables generally.
> 
> From that it wouldn't even be necessary for that variable to be itself
> initialized with a constant expression, but I probably just missed that
> wording, because it (expectably) doesn't work with a final whose initial
> value is not a constant expression itself, nor with a final variable
> that isn't immediately initialized.
> 

Scope. If it is in the scope it is valid.

-- 

You will gain money by an immoral action.

[toc] | [prev] | [next] | [standalone]


#29649

FromAndreas Leitgeb <avl@auth.logic.tuwien.ac.at>
Date2014-08-12 21:15 +0000
Message-ID<slrnlul106.fp3.avl@login.logic.tuwien.ac.at>
In reply to#29642
Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> writes:
>>It never before occurred to me, that one could define a local constant
>>within a method (e.g.: final int foo = 42;) AND use it for a case label
>>in a switch statement.
>   I just had a look into my own (German language) tutorial,
>   and found it mentioned there in the section »Konstantheit
>   von case-Marken«.
> http://www.purl.org/stefan_ram/pub/switch_java

Ah, thanks.  So it obviously isn't as obscure an feature as I thought ;-)

PS: I hope, the students reading the tutorial won't adopt the bracing
    style used there. Apart from my personal dislike, it also has a
    technical disadvantage with respect to comparing different versions
    of a source file with lines added or removed in one.   Otoh, I do
    understand, that it serves as a way of saving vertical space (or
    even trees, if printed out) just for the sake of the tutorial.

[toc] | [prev] | [next] | [standalone]


#29650

FromSilvio <silvio@internet.com>
Date2014-08-12 23:20 +0200
Message-ID<53ea851c$0$2950$e4fe514c@news2.news.xs4all.nl>
In reply to#29649
On 08/12/2014 11:15 PM, Andreas Leitgeb wrote:
> Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>> Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> writes:
>>> It never before occurred to me, that one could define a local constant
>>> within a method (e.g.: final int foo = 42;) AND use it for a case label
>>> in a switch statement.
>>    I just had a look into my own (German language) tutorial,
>>    and found it mentioned there in the section »Konstantheit
>>    von case-Marken«.
>> http://www.purl.org/stefan_ram/pub/switch_java
>
> Ah, thanks.  So it obviously isn't as obscure an feature as I thought ;-)
>
> PS: I hope, the students reading the tutorial won't adopt the bracing
>      style used there. Apart from my personal dislike, it also has a
>      technical disadvantage with respect to comparing different versions
>      of a source file with lines added or removed in one.   Otoh, I do
>      understand, that it serves as a way of saving vertical space (or
>      even trees, if printed out) just for the sake of the tutorial.
>

Totally agree. It looks like what a drunk Lisp programmer would do to a 
Java source trying to make sense of it.

[toc] | [prev] | [next] | [standalone]


#29651

FromSilvio <silvio@internet.com>
Date2014-08-12 23:22 +0200
Message-ID<53ea85ae$0$2950$e4fe514c@news2.news.xs4all.nl>
In reply to#29649
On 08/12/2014 11:15 PM, Andreas Leitgeb wrote:
> Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>> Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> writes:
>>> It never before occurred to me, that one could define a local constant
>>> within a method (e.g.: final int foo = 42;) AND use it for a case label
>>> in a switch statement.
>>    I just had a look into my own (German language) tutorial,
>>    and found it mentioned there in the section »Konstantheit
>>    von case-Marken«.
>> http://www.purl.org/stefan_ram/pub/switch_java
>
> Ah, thanks.  So it obviously isn't as obscure an feature as I thought ;-)
>
> PS: I hope, the students reading the tutorial won't adopt the bracing
>      style used there. Apart from my personal dislike, it also has a
>      technical disadvantage with respect to comparing different versions
>      of a source file with lines added or removed in one.   Otoh, I do
>      understand, that it serves as a way of saving vertical space (or
>      even trees, if printed out) just for the sake of the tutorial.
>

Totally agree. It looks like what a drunk Lisp programmer would do to a 
Java source trying to make sense of it.

[toc] | [prev] | [next] | [standalone]


#29677

FromLew <lewbloch@gmail.com>
Date2014-08-15 15:22 -0700
Message-ID<0d3ba8f9-586e-428f-9982-15b4c4da4690@googlegroups.com>
In reply to#29642
On Tuesday, August 12, 2014 9:56:18 AM UTC-7, Andreas Leitgeb wrote:
> It never before occurred to me, that one could define a local constant
> within a method (e.g.: final int foo = 42;) AND use it for a case label
> in a switch statement.
> 
> I'm a bit curious about whether this is an old-age feature that I've
> been missing out for a very long time, or if this just came in recently...

Long-time feature.

> I had a look at the JLS, too: the description of switch(§14.11) refers to
> term constant expression (§15.28), which further refers to constant
> variables (§4.12.4), which is about final variables generally.

"Constant variables" are not about 'final' variables generally.

> From that it wouldn't even be necessary for that variable to be itself
> initialized with a constant expression, but I probably just missed that
> wording, because it (expectably) doesn't work with a final whose initial
> value is not a constant expression itself, nor with a final variable
> that isn't immediately initialized.

In order to be a constant variable, the variable must be both 'final' and initialized with a constant expression.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#29682

FromAndreas Leitgeb <avl@auth.logic.tuwien.ac.at>
Date2014-08-16 00:24 +0000
Message-ID<slrnlut96n.fp3.avl@login.logic.tuwien.ac.at>
In reply to#29677
Lew <lewbloch@gmail.com> wrote:
> On Tuesday, August 12, 2014 9:56:18 AM UTC-7, Andreas Leitgeb wrote:
>> It never before occurred to me, that one could define a local constant
>> within a method (e.g.: final int foo = 42;) AND use it for a case label
>> in a switch statement.
>> I'm a bit curious about whether this is an old-age feature that I've
>> been missing out for a very long time, or if this just came in recently...
> Long-time feature.
ok.

>> I had a look at the JLS, too: the description of switch(§14.11) refers to
>> term constant expression (§15.28), which further refers to constant
>> variables (§4.12.4), which is about final variables generally.
> "Constant variables" are not about 'final' variables generally.

Section (§4.12.4)'s title is literally "final Variables".

Only now, I noticed, that within this chapter the term "constant variable"
is coined with the expected meaning.

Thanks (case closed from my pov)

[toc] | [prev] | [next] | [standalone]


#29718

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-08-18 23:46 -0700
Message-ID<tlr5v9dbqdlbi0pqo43pnapptb8akcroe3@4ax.com>
In reply to#29682
On Sat, 16 Aug 2014 00:24:55 +0000 (UTC), Andreas Leitgeb
<avl@auth.logic.tuwien.ac.at> wrote, quoted or indirectly quoted
someone who said :

>Only now, I noticed, that within this chapter the term "constant variable"
>is coined with the expected meaning.

That is kind of a goofy term.  What it really means is a final whose
value is known at compile time, even if indirectly. Perhaps "primal"
or "cknown".

Java just initialises in textual order.

In tidying, I sometimes screw things up so there is a reference before
a definition. Java is not like a spreadsheet sorting out natural
initialization order.

One brute force way to avoid this is to put all your initialisation
values in a static init block, and put that block after all your
static declarations.

-- 
Roedy Green Canadian Mind Products http://mindprod.com
Errors using inadequate data are much less than those using no data at all. 
~ Charles Babbage (born: 1791-12-26 died: 1871-10-18 at age: 79)

[toc] | [prev] | [next] | [standalone]


#29781

FromAndreas Leitgeb <avl@auth.logic.tuwien.ac.at>
Date2014-08-21 13:57 +0000
Message-ID<slrnlvbume.fp3.avl@login.logic.tuwien.ac.at>
In reply to#29718
Roedy Green <see_website@mindprod.com.invalid> wrote:
> On Sat, 16 Aug 2014 00:24:55 +0000 (UTC), Andreas Leitgeb wrote:
>> Only now, I noticed, that within this chapter the term "constant variable"
>> is coined with the expected meaning.
> Java just initialises in textual order.
>
> In tidying, I sometimes screw things up so there is a reference before
> a definition. Java is not like a spreadsheet sorting out natural
> initialization order.

At least, it doesn't go unnoticed.  If a dependent "constant variable"
ends up before what it depends on, then you'd get:
" ... error: illegal forward reference

It might be more delicate, when you have a circular definition of
constants in separate compilation units (.java files), but I'd
expect the compiler to catch even that.

> One brute force way to avoid this is to put all your initialisation
> values in a static init block, and put that block after all your
> static declarations.

If you put them there, then they'd no longer be "constant variables"
and you then couldn't use them for case-labels in switch-bodies.

PS: I agree, that "constant variable" is an oxymoron.
  A better term might have been "(constant) vari-un-able" ;-)

[toc] | [prev] | [next] | [standalone]


#29786

FromJoerg Meier <joergmmeier@arcor.de>
Date2014-08-21 18:52 +0200
Message-ID<rbtwwg9my3or.ismdzx8ghbbp$.dlg@40tude.net>
In reply to#29781
On Thu, 21 Aug 2014 13:57:33 +0000 (UTC), Andreas Leitgeb wrote:

> Roedy Green <see_website@mindprod.com.invalid> wrote:
>> On Sat, 16 Aug 2014 00:24:55 +0000 (UTC), Andreas Leitgeb wrote:
>>> Only now, I noticed, that within this chapter the term "constant variable"
>>> is coined with the expected meaning.
>> Java just initialises in textual order.

>> In tidying, I sometimes screw things up so there is a reference before
>> a definition. Java is not like a spreadsheet sorting out natural
>> initialization order.
> At least, it doesn't go unnoticed.  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.

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

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#29787

FromMike Amling <mamling@chaff.us>
Date2014-08-21 13:19 -0500
Message-ID<c5mrg1F8ls0U1@mid.individual.net>
In reply to#29786
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==

[toc] | [prev] | [next] | [standalone]


#29790

FromJoerg Meier <joergmmeier@arcor.de>
Date2014-08-21 22:41 +0200
Message-ID<18tprmtmw1wm5$.8urqx3khiqo6.dlg@40tude.net>
In reply to#29787
On Thu, 21 Aug 2014 13:19:04 -0500, Mike Amling wrote:

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

I must admit that I posted with only half my brain on the topic and totally
forgot that we were talking about more than just final variables (and
obviously you're also right about the first 'final'). Kind of funny since I
brought up this exact kind of code earlier in this thread.

In my defense, I had construction people tearing down wall covers in the
next room all day.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [next] | [standalone]


#29788 — [OT] Re: local constants with switch

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-08-21 14:42 -0400
Subject[OT] Re: local constants with switch
Message-ID<lt5eir$c5p$1@dont-email.me>
In reply to#29786
On 8/21/2014 12:52 PM, Joerg Meier wrote:
> On Thu, 21 Aug 2014 13:57:33 +0000 (UTC), Andreas Leitgeb wrote:
>> [...]
>> 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.

     "Good old C" had no such notion at all.  "ANSI C" introduced
`const', which doesn't mean "constant" but something closer to
"read-only unless you bend the rules and risk the compiler's wrath."

-- 
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#29789 — Re: [OT] Re: local constants with switch

FromAndreas Leitgeb <avl@auth.logic.tuwien.ac.at>
Date2014-08-21 19:21 +0000
SubjectRe: [OT] Re: local constants with switch
Message-ID<slrnlvchlq.fp3.avl@login.logic.tuwien.ac.at>
In reply to#29788
Eric Sosman <esosman@comcast-dot-net.invalid> wrote:
> On 8/21/2014 12:52 PM, Joerg Meier wrote:
>> On Thu, 21 Aug 2014 13:57:33 +0000 (UTC), Andreas Leitgeb wrote:
>>> [...]
>>> 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.
>      "Good old C" had no such notion at all.  "ANSI C" introduced
> `const', which doesn't mean "constant" but something closer to
> "read-only unless you bend the rules and risk the compiler's wrath."

I remember "constants" in C as preprocessor symbols #define'd to
some literal value.

PS: compiler's wrath for the sin of writing "const" variables may
  nowadays be enforced by the OS, if constant data ends up being
  placed in a read-only memory segment.

[toc] | [prev] | [next] | [standalone]


#29798 — Re: [OT] Re: local constants with switch

FromJoshua Cranmer 🐧 <Pidgeot18@verizon.invalid>
Date2014-08-21 22:30 -0500
SubjectRe: [OT] Re: local constants with switch
Message-ID<lt6dgc$hk0$1@dont-email.me>
In reply to#29789
On 8/21/2014 2:21 PM, Andreas Leitgeb wrote:
> I remember "constants" in C as preprocessor symbols #define'd to
> some literal value.

Off-topic, but great segue to the legendary preprocessor macro:
/* snigger snigger */
#define true false

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

[toc] | [prev] | [next] | [standalone]


#29819 — Re: [OT] Re: local constants with switch

FromSilvio <silvio@internet.com>
Date2014-08-23 14:01 +0200
SubjectRe: [OT] Re: local constants with switch
Message-ID<53f8828e$0$2885$e4fe514c@news2.news.xs4all.nl>
In reply to#29798
On 08/22/2014 05:30 AM, Joshua Cranmer 🐧 wrote:
> On 8/21/2014 2:21 PM, Andreas Leitgeb wrote:
>> I remember "constants" in C as preprocessor symbols #define'd to
>> some literal value.
>
> Off-topic, but great segue to the legendary preprocessor macro:
> /* snigger snigger */
> #define true false
>

I had a friend debug a program for over two hours after I put

#define while if

in his stdio.h after he had put a semicolon in column 500 after the 
closing parenthesis of a for loop of mine. I caught that within minutes 
but felt sorry for him after a while and gave it up.

[toc] | [prev] | [next] | [standalone]


#29823 — Re: [OT] Re: local constants with switch

FromAndreas Leitgeb <avl@auth.logic.tuwien.ac.at>
Date2014-08-23 15:22 +0000
SubjectRe: [OT] Re: local constants with switch
Message-ID<slrnlvhcd6.fp3.avl@login.logic.tuwien.ac.at>
In reply to#29819
Silvio <silvio@internet.com> wrote:
> On 08/22/2014 05:30 AM, Joshua Cranmer 🐧 wrote:
>> On 8/21/2014 2:21 PM, Andreas Leitgeb wrote:
>>> I remember "constants" in C as preprocessor symbols #define'd to
>>> some literal value.
>> Off-topic, but great segue to the legendary preprocessor macro:
>> /* snigger snigger */
>> #define true false
> I had a friend debug a program for over two hours after I put
> #define while if
> in his stdio.h after he had put a semicolon in column 500 after the 
> closing parenthesis of a for loop of mine. I caught that within minutes 
> but felt sorry for him after a while and gave it up.

:-)  Apparently, your friend didn't know about "cc -E"  ...

I guess, in Java one can be a jerk, too, especially with some \u00..'ery:

e.g. to interrupt a big block-comment and import some looks.like.System
hidden in the usual license-legalese block that nobody ever reads. I'd
guess that even most syntax-highlighting editors wouldn't "notice" (and
thus reflect in color) that.

/* ... must not be used while taking a bath in a tank of eels while
 * on an oil rig ... blah yadda ... (+50 more such lines)
 *\u002F import com.company \u002e java.lang.System \u003B \u002F*
 * (50 more lines of yadda blah
 */
Eclipse shows it all green, but the compiler of course sees it.

[toc] | [prev] | [next] | [standalone]


#29829 — Re: [OT] Re: local constants with switch

FromArne Vajhøj <arne@vajhoej.dk>
Date2014-08-23 22:12 -0400
SubjectRe: [OT] Re: local constants with switch
Message-ID<53f94a17$0$291$14726298@news.sunsite.dk>
In reply to#29788
On 8/21/2014 2:42 PM, Eric Sosman wrote:
> On 8/21/2014 12:52 PM, Joerg Meier wrote:
>> On Thu, 21 Aug 2014 13:57:33 +0000 (UTC), Andreas Leitgeb wrote:
>>> [...]
>>> 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.
>
>      "Good old C" had no such notion at all.  "ANSI C" introduced
> `const',

ANSI C is now 25 years old.

>          which doesn't mean "constant" but something closer to
> "read-only unless you bend the rules and risk the compiler's wrath."

Always difficult to discuss such things without a clear definition
of the terms.

But I would say that C const is closer to C# const than to C# readonly.

Arne

[toc] | [prev] | [next] | [standalone]


#29796

FromJim Gibson <jimsgibson@gmail.com>
Date2014-08-21 17:04 -0700
Message-ID<210820141704475420%jimsgibson@gmail.com>
In reply to#29781
In article <slrnlvbume.fp3.avl@login.logic.tuwien.ac.at>, Andreas
Leitgeb <avl@auth.logic.tuwien.ac.at> wrote:

> 
> PS: I agree, that "constant variable" is an oxymoron.
>   A better term might have been "(constant) vari-un-able" ;-)
> 

What about "const-able"?

-- 
Jim Gibson

[toc] | [prev] | [next] | [standalone]


#29797 — [OT] Re: local constants with switch

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2014-08-21 20:50 -0400
Subject[OT] Re: local constants with switch
Message-ID<lt6448$pvi$1@dont-email.me>
In reply to#29796
On 8/21/2014 8:04 PM, Jim Gibson wrote:
> In article <slrnlvbume.fp3.avl@login.logic.tuwien.ac.at>, Andreas
> Leitgeb <avl@auth.logic.tuwien.ac.at> wrote:
>
>>
>> PS: I agree, that "constant variable" is an oxymoron.
>>    A better term might have been "(constant) vari-un-able" ;-)
>>
>
> What about "const-able"?

     "Constable, how would you like to join the River Police?"

      "Oid loik thet very much, Sir!"

      "Huhhh-URK!"

      FX: "Splash"

      "Thenk yew verry much, Sir!"

      -- "Dishonoured" (The Goons)

-- 
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web