Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. Strongly-typed typo

Strongly-typed typo

Scheduled Pinned Locked Moved Clever Code
14 Posts 11 Posters 63 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    elektrowolf
    wrote on last edited by
    #1

    return new Vector3(r * (float)Math.Cos(theta), r * (float)Math.Sign(theta), z);

    And I thought I was safe from typos using a strongly-typed language.. :doh: Took me hours to figure this one out.

    J L V P D 5 Replies Last reply
    0
    • E elektrowolf

      return new Vector3(r * (float)Math.Cos(theta), r * (float)Math.Sign(theta), z);

      And I thought I was safe from typos using a strongly-typed language.. :doh: Took me hours to figure this one out.

      J Offline
      J Offline
      Jorgen Andersson
      wrote on last edited by
      #2

      Sin != Sign

      "When did ignorance become a point of view" - Dilbert

      L 1 Reply Last reply
      0
      • E elektrowolf

        return new Vector3(r * (float)Math.Cos(theta), r * (float)Math.Sign(theta), z);

        And I thought I was safe from typos using a strongly-typed language.. :doh: Took me hours to figure this one out.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        I haven't seen a language yet that imposes (or allows you to impose) a minimal Hamming distance[^] between identifier names. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        S 1 Reply Last reply
        0
        • J Jorgen Andersson

          Sin != Sign

          "When did ignorance become a point of view" - Dilbert

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sign was the sin - sine would be better :rolleyes:

          It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca

          1 Reply Last reply
          0
          • L Luc Pattyn

            I haven't seen a language yet that imposes (or allows you to impose) a minimal Hamming distance[^] between identifier names. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            S Offline
            S Offline
            Steve Wellens
            wrote on last edited by
            #5

            It threw you a curve eh?

            Steve Wellens

            1 Reply Last reply
            0
            • E elektrowolf

              return new Vector3(r * (float)Math.Cos(theta), r * (float)Math.Sign(theta), z);

              And I thought I was safe from typos using a strongly-typed language.. :doh: Took me hours to figure this one out.

              V Offline
              V Offline
              Vasudevan Deepak Kumar
              wrote on last edited by
              #6

              Shouldn't the compiler be a little more proactively smart enough to throw out a little warning at least w.r.t. context-sensitiveness?

              Vasudevan Deepak Kumar Personal Homepage
              Tech Gossips
              The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

              E 1 Reply Last reply
              0
              • V Vasudevan Deepak Kumar

                Shouldn't the compiler be a little more proactively smart enough to throw out a little warning at least w.r.t. context-sensitiveness?

                Vasudevan Deepak Kumar Personal Homepage
                Tech Gossips
                The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                E Offline
                E Offline
                elektrowolf
                wrote on last edited by
                #7

                Vasudevan Deepak Kumar wrote:

                Shouldn't the compiler be a little more proactively smart enough to throw out a little warning at least w.r.t. context-sensitiveness?

                How should he possibly do that? Best solution I can come up with is providing a Math.PolarToCartesian function...

                V 1 Reply Last reply
                0
                • E elektrowolf

                  Vasudevan Deepak Kumar wrote:

                  Shouldn't the compiler be a little more proactively smart enough to throw out a little warning at least w.r.t. context-sensitiveness?

                  How should he possibly do that? Best solution I can come up with is providing a Math.PolarToCartesian function...

                  V Offline
                  V Offline
                  Vasudevan Deepak Kumar
                  wrote on last edited by
                  #8

                  With other tan/cos being used in the same context it can alert if sign is being inadvertently used in lieu of sine?

                  Vasudevan Deepak Kumar Personal Homepage
                  Tech Gossips
                  The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                  S P 2 Replies Last reply
                  0
                  • V Vasudevan Deepak Kumar

                    With other tan/cos being used in the same context it can alert if sign is being inadvertently used in lieu of sine?

                    Vasudevan Deepak Kumar Personal Homepage
                    Tech Gossips
                    The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                    S Offline
                    S Offline
                    S Senthil Kumar
                    wrote on last edited by
                    #9

                    Well, the "compiler" knows only the language, not the libraries. There is no way it can possibly know beforehand about the existence of a Math class with two methods, Sign and Sine, much less associate Tan and Sine and figure out that the user probably wanted Sine instead of Sign. A source code analysis tool like FxCop could probably do a better job at this.

                    Regards Senthil _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

                    1 Reply Last reply
                    0
                    • E elektrowolf

                      return new Vector3(r * (float)Math.Cos(theta), r * (float)Math.Sign(theta), z);

                      And I thought I was safe from typos using a strongly-typed language.. :doh: Took me hours to figure this one out.

                      P Offline
                      P Offline
                      peterchen
                      wrote on last edited by
                      #10

                      ouch!

                      Agh! Reality! My Archnemesis![^]
                      | FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server.

                      1 Reply Last reply
                      0
                      • V Vasudevan Deepak Kumar

                        With other tan/cos being used in the same context it can alert if sign is being inadvertently used in lieu of sine?

                        Vasudevan Deepak Kumar Personal Homepage
                        Tech Gossips
                        The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                        P Offline
                        P Offline
                        peterchen
                        wrote on last edited by
                        #11

                        In Addition, even if the compiler knew the libraries, there's no distinct way to tell right from wrong - Cos(x)*Sign(x) is as valid an operation as Cos(x)*Sin(x). The latter may be more common overall, but that doesn't mean it has to be for my application. (Besides, I don't believe much in the total greatness of "people who used Math.Cos also used the following functions...". Even if it's great for discovering things you might like, you'll have a hard time finding something special.)

                        Agh! Reality! My Archnemesis![^]
                        | FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server.

                        1 Reply Last reply
                        0
                        • E elektrowolf

                          return new Vector3(r * (float)Math.Cos(theta), r * (float)Math.Sign(theta), z);

                          And I thought I was safe from typos using a strongly-typed language.. :doh: Took me hours to figure this one out.

                          D Offline
                          D Offline
                          Derek Viljoen
                          wrote on last edited by
                          #12

                          As someone who started out coding with 'vi' I find it amusing what people find annoying in modern IDEs. Sad that you wasted so much time, but if you think about everything the IDE was doing to help you ... not a lot to complain about there.

                          D D 2 Replies Last reply
                          0
                          • D Derek Viljoen

                            As someone who started out coding with 'vi' I find it amusing what people find annoying in modern IDEs. Sad that you wasted so much time, but if you think about everything the IDE was doing to help you ... not a lot to complain about there.

                            D Offline
                            D Offline
                            dawmail333
                            wrote on last edited by
                            #13

                            He never said he found the IDE annoying: he was just saying that he mistakenly though that he could avoid typos by using a strongly typed language. Silly man :laugh: Typos are inveitable. Truly so. ;P

                            1 Reply Last reply
                            0
                            • D Derek Viljoen

                              As someone who started out coding with 'vi' I find it amusing what people find annoying in modern IDEs. Sad that you wasted so much time, but if you think about everything the IDE was doing to help you ... not a lot to complain about there.

                              D Offline
                              D Offline
                              Dave Calkins
                              wrote on last edited by
                              #14

                              nothing to do with IDEs in this one. you could write that code in vi and have the same problem :)

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups