L
Lew
blue said:It was intended as constructive criticism.
I took it as such.
blue said:It was intended as constructive criticism.
Because the JLS says so.
blue said:It was intended as constructive criticism. As, I believe, are some of the
posts you make that I characterized as spelling flames and similarly, but
which maybe could be improved upon, for example by never neglecting the
core point of the preceding post and sometimes by recognizing a lost cause
(such as attempts to educate spammers and trolls).
Perhaps you don't agree.
Carry on, then.
It seems that in your eagerness to criticize me personally (and, I
notice, not the others who gave the same answer with somewhat more
detail) that you completely ignored the point I made.
I was giving the only actual, valid answer to the question.
Java is the only language that receives criticism from its adherents
rather than blind devotion.
"Why is it that way?" is not a useful question
and always the trivial answer is the correct one, "Because
that's the definition of the language".
Now, were one to ask, "Should this change?" that would be useful.
So next time, blue indigo, do not rush to judgment
but consider why I gave the answer I did, and incorporate the
possibility that the answer was serious, thoughtful and relevant.
The "#if 0" method was the canonical way to suppress a
bunch of code from compilation in early C days (a '/* */' would not do
the trick in full generality, since such comments do not nest).
According to blue indigo said:On Mon, 5643 Sep 1993 22:31:37 +0000, Thomas Pornin wrote:
[snip]
Regardless of what the compiler thinks about exceptions, the JVM will
happily accept all of these because transgressions of the "checked
exceptions" rules do not impact the safety of the sandbox model that the
JVM implements.
And transgressions of the "dead code" rules do? How?
Yes, although a bit indirectly. [snip lots of details]
Better would have been to require /* */ comments to nest properly in C++,
and eventually backport THAT to C. It wouldn't have even broken anything,
since */ is not legal outside of a comment, so changing the parsing rules
for comments in the appropriate manner wouldn't have caused valid code to
suddenly become comments in pre-existing compilable code.
/*/*char* txt1 = "*/char* txt2="*/";
Yes, of course it would have to take quotation marks into account as
well as /* and */.
The corner case you point out ought to be rare in practise. How common is
it for string literals containing C source to occur in C source? Outside
of quines and IOCCC submissions, anyway.
Thomas Pornin said:So the "#if 0" is from early C days, while "if (0)" is the new,
reformed way. Apparently, Sun chose to follow Ritchie's ideas
in that matter.
- But it takes a lot more typing to insert "// " at the start of each of
1000 lines than to insert "/*<RET>" at the top and "*/<RET>" at the bottom.
Test01.java:4: exception java.io.IOException is never thrown in body
of corresponding try statement
try {} catch (java.io.IOException e) {}
blue said:That must rank up there on the "all-time top 100 boneheaded decisions"
list. "Such comments do not nest," that is. They even have a distinct left
and right delimiter, so it would have been trivial to make them nest
appropriately, and doing so would have made it very easy to comment out
large blocks of code containing pre-existing comments. Yet they did not,
probably out of sheer laziness.
// comments were introduced to C++ (and later backported to C) partly to
address this, only to run into their own problems:
- You can now use /* */ to easily comment out a lot of code containing
only // comments.
- You can now use // to comment out a lot of code containing arbitrary types
of comments.
- But it takes a lot more typing to insert "// " at the start of each of
1000 lines than to insert "/*<RET>" at the top and "*/<RET>" at the bottom.
Better would have been to require /* */ comments to nest properly in C++,
and eventually backport THAT to C. It wouldn't have even broken anything,
since */ is not legal outside of a comment, so changing the parsing rules
for comments in the appropriate manner wouldn't have caused valid code to
suddenly become comments in pre-existing compilable code.
Java would have benefited too, since it inherited the C++ system of
commenting syntax.
Roedy said:I too find that annoying. I would like to build a catch, especially
into in interface for an exception I MIGHT want some day.
blue said:Yes, of course it would have to take quotation marks into account as
well as /* and */.
I thought that went without saying, sorry mate.
The corner case you point out ought to be rare in practise. How common is
it for string literals containing C source to occur in C source? Outside
of quines and IOCCC submissions, anyway.
blue said:That must rank up there on the "all-time top 100 boneheaded decisions"
list. "Such comments do not nest," that is. They even have a distinct left
and right delimiter, so it would have been trivial to make them nest
appropriately, and doing so would have made it very easy to comment out
large blocks of code containing pre-existing comments. Yet they did not,
probably out of sheer laziness.
Better would have been to require /* */ comments to nest properly in C++,
and eventually backport THAT to C. It wouldn't have even broken anything,
since */ is not legal outside of a comment,
Arne said:Classes do not have to throw all exceptions declared in their
interface.
Arne said:Changes that impact existing code are generally frowned at no matter
if it is 10%, 0.1% or 0.001% of existing program that will be
impacted.
Lew said:I just got bitten by a Java 6 change that broke existing code.
This then becomes a considerably more complex change than what you
outline above and one that is sure to meet with, shall we say,
spirited debate in the larger C community.
That is really of no interest whatsoever. All that needs to be
demonstrated is that there can exist code that will break after the
change and such a demonstration, however eccentric, is sufficient to
disprove the claim that the change can safely be introduced with no
further ado. As a minor point, I also don't think the situation is
quite as rare as you make out(*).
As we have now seen, such a change can only be made after very careful
consideration and thorough discussion in the programmer community.
*) C code in string literals is not necessary, it was a consequence of
my example being based on the notion of the programmer commenting out
parts of his code to try an alternative. The same problem would
manifest itself with e.g.
/* these are the operators supported
/* by our calculator */
char* operators = "+-*/=";
doSomething();
// I can easily toggle doSomethingElse and doSomeOtherThing() call by
// adding a */ at the end of the following line
/*
doSomethingElse();
doSomeOtherThing(); /**/
doSomeFinalThing(); // */
So, tracking two sets of delimeters is "considerably more complex" than
tracking one. I did not know that. Thanks.
Considering that I had suggested that C should have done this from the
outset (...)
(...) This sort of
code is not especially common, either -- and consider that if five symbols
are listed in arbitrary order, the odds that a particular two will happen
to be adjacent and in a particular order are not particularly high.
(...)
Daniel Pitts had a different sort of corner-case, not involving string
literals:
(...)
I consider that kind of fiddly stuff to be an antipattern. #if(DEBUG) is
far, far better, much cleaner and more readable. Moreover, in the specific
case of Java it is not even applicable.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.