Equals Operator

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roger

    Equals Operator

    What did MS not take the chance to change
    the silly == operator when they designed C#,
    to something reasonable like = ?
    Why change the universal meaning of = ?

    Wouldn't it be better to have:
    Assignment := //or something else
    Equal = //but keep = to be =

    My view,
    Roger


  • Jon Skeet [C# MVP]

    #2
    Re: Equals Operator

    Roger <roger@pcsreven uecontrol.com> wrote:[color=blue]
    > What did MS not take the chance to change
    > the silly == operator when they designed C#,
    > to something reasonable like = ?
    > Why change the universal meaning of = ?
    >
    > Wouldn't it be better to have:
    > Assignment := //or something else
    > Equal = //but keep = to be =[/color]

    Because it's not the universal meaning of =. In particular, that's not
    the meaning of = in C, C++ or Java, which is what the syntax of C# is
    based on.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Howard Swope

      #3
      Re: Equals Operator

      Roger:

      The language is called C#. Much of the syntax is taken from C/C++ design. I
      lot of the problems that were caused by == in C / C++ are caught be the C#
      compiler. You can't get away with stuff like:

      if (a = b)

      In most cases this is a typo in C / C++ but the comiler wouldn't flag it. If
      [b] was zero it would come out false else it would be true. C# will yell at
      you if you try this.

      Problem solved.

      "Roger" <roger@pcsreven uecontrol.com> wrote in message
      news:OPqDhoccFH A.2936@tk2msftn gp13.phx.gbl...[color=blue]
      > What did MS not take the chance to change
      > the silly == operator when they designed C#,
      > to something reasonable like = ?
      > Why change the universal meaning of = ?
      >
      > Wouldn't it be better to have:
      > Assignment := //or something else
      > Equal = //but keep = to be =
      >
      > My view,
      > Roger
      >
      >[/color]


      Comment

      • Michael S

        #4
        Re: Equals Operator


        "Roger" <roger@pcsreven uecontrol.com> wrote in message
        news:OPqDhoccFH A.2936@tk2msftn gp13.phx.gbl...[color=blue]
        > What did MS not take the chance to change
        > the silly == operator when they designed C#,
        > to something reasonable like = ?
        > Why change the universal meaning of = ?
        >
        > Wouldn't it be better to have:
        > Assignment := //or something else
        > Equal = //but keep = to be =
        >
        > My view,
        > Roger
        >[/color]

        I also think pascal style makes more sense.

        As I'm used to Delphi I typically assign when I should compare, which makes
        for some funny bugs when I have (the misfortune) to code in C/C++. My Bad.

        But as C# protects you from doing stupid things with assignments, it's no
        big deal.
        And as I do 99% of my coding in C# nowadays, I seldom make these kind of
        mistakas anymore.

        - Michael S


        Comment

        Working...