1 2 3 4 5 Previous Next 70 Replies Latest reply on Mar 10, 2010 6:33 PM by 796440 Go to original post
      • 60. Re: Ternary operator
        jschellSomeoneStoleMyAlias
        atch7 wrote:
        jverd wrote:
        atch7 wrote:
        kevinaworkman wrote:
        atch7 wrote:
        Another thing is that it is an operator just like '+++' or '-' and as long as it have correct operands on each of its side it should work without making any problems.
        What? Why? Says who? This doesn't make any sense.
        Exactly. Who and What. As Java never has been standardized and for some strange reasons it doesn't look like it will be in near by future.
        What do you even mean by this? In what way is Java "not standardized" that C++ is?
        Are you really serious asking this question? Java isn't standardized, C++ is. Nothing more to say. If you don't understand what does it mean - STFW;
        Which has absolutely nothing to do with any of your points of course.

        PL/SQL isn't "standardized" either but that doesn't mean that it must follow the 'standard' of some other completely different language to be correct.
        • 61. Re: Ternary operator
          jschellSomeoneStoleMyAlias
          atch7 wrote:
          As a matter of fact this kind of way is used all the time in C++ code and it's even preferred to if/then/else structure. So you would be entirely wrong if you would file it as a bug. Obviously you prefer to drive fiesta to ferrari.
          Don't know about you but I worked at one consulting company with 300 C++ developers (unix only) and that code never appeared there. Nor did any of the customers (consulting remember) mention the lack. Same for another company with 30 developers. No lack there.

          And I was a principal reviewer by the way along with creating coding standards as part of process control standards. So seems like I would have remembered it happening at least once.

          I have 3 books on standard usage of C/C++. I can't recall seeing it suggested there.

          I read C/C++ Users Journal for years. And Dr Dobbs. I don't recall seeing that.

          So perhaps you could back up your assertion with something more substantial that just your say so?
          • 62. Re: Ternary operator
            jschellSomeoneStoleMyAlias
            atch7 wrote:
            And at what point did I say anything about reviewing code? I would only like to have the freedom to write what I want as long as syntax is correct.
            That certainly explains a lot.

            I don't write code to be 'free'. I write code to support businesses in making money. As a professional I attempt to write code in such a way that it lowers the overall cost to the company for the entire process of developing code. That means that it must be written to support long term maintainability. And not just because I feel like experimenting with something one day.
            And if I see something that is illogical I just say so.
            The fact that you don't understand the logic doesn't make it illogical.
            And just because Sun says that return value of ?: has to be assigned somewhere it doesn't necessary mean that it does make sense.
            I don't find that the language "whitespace" makes much sense. It is fun but not practical.

            Conversely java, just like "whitespace" and C and C++ has a defined language. And the definition is very precise in this regard anyone that claims it is illogical wouldn't seem to actually understand what having a defined language means.
            • 63. Re: Ternary operator
              jschellSomeoneStoleMyAlias
              atch7 wrote:
              Not to mention of course that there are probably many more people that can claim that they can drive a ferrari versus those that can actually do so in a way that actually uses the power appropriately.
              Following your reasoning you would prefer pulling a horse trailer with ford fiesta. Bravo. Good choice.
              And with Ferrari at least I have a chance (if I'm not good enough) to experience something and at least I'm given a chance to improve my style and techniques and I'm free with my choice of thinking.What can you expect from driving a fiesta? I'm not constrained to one and only correct way of thinking (designed by Sun). I can drive slow, I can drive fast - I decide, well you don't have this choice driving fiesta.
              Again this comment suggests that either you do not write code for a living or you simply do not understand the costs to a business of producing software. Or you don't care.
              • 64. Re: Ternary operator
                jschellSomeoneStoleMyAlias
                KelVarnson wrote:
                jduprez wrote:
                Has it been mentioned already that this whole discussion has nothing to do with Swing itself?
                How else could we get yawmark, jverd, and jschell to come slumming here?
                You certainly don't want me attempting to answer real questions here. Not a good idea at all.
                • 65. Re: Ternary operator
                  796440
                  atch7 wrote:
                  jverd wrote:
                  atch7 wrote:
                  It's another of java's illogicalities. In my code mentioned in original post if I have to use a ternary operator to do what I want it to do:
                  1. I have to make sure that I'm using methods which return some value different than void and
                  2. I have to assign it to some completely unnecessary variable.

                  So following this logic I can't say:

                  int == 0 ? setVisible(true) : setVisible(false);

                  but providing that I have method definition:

                  int setSelectable(int a)
                  {
                  //do something
                  //and just for sake of making this to work I have to have return statement
                  return a;
                  }

                  having that now I can write

                  int a = i == 0 ? setSelectable(1) : setSelectable(0);

                  Pathetic, illogical and completely java like behavior.
                  This is the rant of a child who's bitter because the world doesn't work the way he assumes it should.

                  The behavior only seems illogical to you because you have the mistaken assumption that the purpose of the operator is to be an equivalent to an if statement. That's not its purpose.
                  Quote from sun's website:
                  "Another conditional operator is ?:, which can be thought of as shorthand for an if-then-else statement"
                  Okay, well, maybe that's why you have that mistaken assumption then.
                  So who is wrong you or they?
                  They are, obviously. The behavior you observed proves it.

                  Or maybe not "wrong" so much as "poorly worded."
                  • 66. Re: Ternary operator
                    796440
                    atch7 wrote:
                    jverd wrote:
                    atch7 wrote:
                    kevinaworkman wrote:
                    atch7 wrote:
                    Another thing is that it is an operator just like '+++' or '-' and as long as it have correct operands on each of its side it should work without making any problems.
                    What? Why? Says who? This doesn't make any sense.
                    Exactly. Who and What. As Java never has been standardized and for some strange reasons it doesn't look like it will be in near by future.
                    What do you even mean by this? In what way is Java "not standardized" that C++ is?
                    Are you really serious asking this question? Java isn't standardized, C++ is. Nothing more to say. If you don't understand what does it mean -
                    Defined "standardized." You mean because C++ is defined by by an ISO or IEEE or ACM or some other body's standard? So what? That doesn't mean anything. Perhaps you think that C++'s syntax and operators are defined against some broader standard? That's not the case. Each language defines its own syntax, operators, etc. The conditional (ternary) operator is not some global standard that C++ has adopted properly and Java has not.
                    STFW;
                    This has been explained to you before, but I'll type it more slowly this time to maybe you'll understand. It's up to you to provide support for your arguments, not me.

                    Edited by: jverd on Mar 10, 2010 8:57 AM
                    • 67. Re: Ternary operator
                      796440
                      atch7 wrote:
                      jverd wrote:
                      atch7 wrote:
                      Another thing is that it is an operator just like '+' or '-' and as long as it have correct operands on each of its side it should work without making any problems.
                      And that's exactly what it does.

                      What you're attempting is the equivalent of this:
                      public class Foo() {
                      public void x() {}
                      
                      public void y() {}
                      }
                      
                      ...
                      
                      Foo foo = new Foo();
                      int z = foo.x() + foo.y();
                      No, it is not equivalent to this.
                      Yes, it is.

                      You were putting methods that return void where an expression is required.
                      • 68. Re: Ternary operator
                        796440
                        atch7 wrote:
                        jverd wrote:
                        atch7 wrote:
                        jduprez wrote:
                        AFAIC, I'm happy that you're giving your point of view about your personal preference, or style. But I side with the others that there is nothing illogical in this design choice of the Java language per se (what is somewhat illogical is that the way return values can be silently ignored is not consistent with this).
                        1+1
                        Because what is java supposed to do with it?
                        Well, just execute it
                        Execute what? an operation that has no side-effect whatsoever?
                        Well, maybe I would like to check how fast adding is executed without assigning?
                        So, the language should support useless syntax in order to enable you to do a useless benchmark?
                        So if the language doesn't support useless syntax why on the other hand I'm allowed to write something like this:
                        Try actually paying attention to what people are writing.

                        I never said it doesn't support any useless syntax. I'm saying that your attitude is that it should support a particular useless syntax.
                        I'm sure that you have java like reasoning for this behavior as well. And I'm also sure that you don't see anything wrong that java allows this syntax but forbids the former.
                        I don't know and don't care why one is allowed ant not the other. I suspect there is some logical justification for it. Quite possibly there aren't rules specifically, directly allowing or forbidding either of these, but the fact that one is allowed and not the other falls out naturally from other rules, and it would have added additional complexity to the language to change it, for no benefit. But it really doesn't matter to me one bit.

                        Edited by: jverd on Mar 10, 2010 9:01 AM
                        • 69. Re: Ternary operator
                          796440
                          atch7 wrote:
                          I would only like to have the freedom to write what I want as long as syntax is correct.
                          You can.
                          And if I see something that is illogical I just say so.
                          You personally think it's illogical. Others who are smarter than you disagree.
                          And just because Sun says that return value of ?: has to be assigned somewhere it doesn't necessary mean that it does make sense.
                          Nothing says it has to be assigned somewhere. But whatever the JLS says about it is, by definition, the correct syntax.

                          You truly do seem to believe that the conditional operator has some inherent proper syntax and that Java is subverting it. This is not the case.
                          • 70. Re: Ternary operator
                            796440
                            atch7 wrote:
                            jschell wrote:
                            atch7 wrote:
                            jduprez wrote:
                            Your example is another sort of Java's stronger checking, I see nothing awkward in it, but my mind is sure formatted after working with Java for a while (with a C >background mind you, and I'm happy I made the shift).
                            I'm sorry but if someone tells me that s/he is happy after switching from C/C++ to Java/C# etc. I just feel like they choosing easy, safe ride which is unfortunately also very boring and without any excitement (just like driving ford fiesta) on the other hand, yes, driving ferrari (read C/C++) you may injure yourself or even die, but the emotions and power is something that is worth dying for. Thats why I prefer to drive ferrari to ford fiesta.
                            I suspect that you would also attempt to go four wheeling in your ferrari while pulling a horse trailer.

                            Others might prefer to pick a vehicle based on the needs of the journey rather than blindly insisting on a single one.

                            Not to mention of course that there are probably many more people that can claim that they can drive a ferrari versus those that can actually do so in a way that actually uses the power appropriately.
                            Following your reasoning you would prefer pulling a horse trailer with ford fiesta. Bravo. Good choice.
                            That does not follow at all. Try paying attention.
                            1 2 3 4 5 Previous Next