Should programming languages continue to use equals sign for assignment?

Should programming languages continue to use equals sign for assignment?

CRIME Shirt $21.68

UFOs Are A Psyop Shirt $21.68

CRIME Shirt $21.68

  1. 2 months ago
    Anonymous

    No. I think <- or something similar is better is better.

    • 2 months ago
      Anonymous

      Hieroglyph D53

    • 2 months ago
      Anonymous

      No. Not only is it not mathematically correct, it also prevents us from using the equals sign for testing equality, forcing us to do strange stuff like ==. This has also led to security vulnerabilities, both unintentional and intentional: https://freedom-to-tinker.com/2013/10/09/the-linux-backdoor-attempt-of-2003/

      <- in many languages would cause problems, as does x<-1 refer to an assignment or whether x is less than -1? For some languages that already heavily use arrows it could be fine.

      There is no assignment operator in mathematics because there is no memory to store a value. Equality is not the same as assignment.

      In mathematical descriptions of algorithms ":=" is used.

      "let x be ____"
      sigma notation?

      In a mathematical context "let" implies that the previous statements still hold, so something like:
      let x be 1
      let x be 2

      would be mathematically wrong.
      I have no problem with something like
      set x to 1
      set x to 2

      other than it being verbose.

      I think := is ideal in concise languages, and set or something similar is best in verbose languages.

      • 2 months ago
        Anonymous

        I like the cpp2 solution, where full declaration syntax is IDENTIFIER: TYPE = VALUE, but you can usually leave type up to inference and write IDENTIFIER := VALUE.
        It bastardizes the math notation a bit by splitting :=, but it's compact and it feels natural to just omit the type.

      • 2 months ago
        Anonymous

        = for comparison
        := for assignment

        s= to set a variable if a condition was ever true
        r= to reset a variable if a condition was ever true

        I like the cpp2 solution, where full declaration syntax is IDENTIFIER: TYPE = VALUE, but you can usually leave type up to inference and write IDENTIFIER := VALUE.
        It bastardizes the math notation a bit by splitting :=, but it's compact and it feels natural to just omit the type.

        Drop the equals sign.
        Assignment is just an abstraction around a register of memory. It should use the same syntax as goto.
        x: 2

        • 2 months ago
          Anonymous

          I don't follow. How is a jump to a specific program address like writing a value to a register?

          • 2 months ago
            Anonymous

            Ideally, the programmer should have control of the memory layout.
            So a variable is just a jump to the memory address of its contents.

          • 2 months ago
            Anonymous

            You don't know what a jump is, but you're pretending to. Are you a Black?

          • 2 months ago
            Anonymous

            1. Not everything is x86
            2. You have a finite amount of actual registers
            This means a generic variable needs to be a goto to a routine to put a value in a register.
            So, abstract the boilerplate away, let the compiler optimize register use, and lastly, the actual goto keyword is reserved for breaking scope. Otherwise variables are local to scope (or use local keyword).

          • 2 months ago
            Anonymous

            Black person, you have no idea what you're talking about. You're inventing gibberish, which is what Black folk are good at.

      • 2 months ago
        Anonymous

        Programming is not mathematics so it doesn't matter.

      • 2 months ago
        Anonymous

        ><- in many languages would cause problems, as does x<-1 refer to an assignment or whether x is less than -1? For some languages that already heavily use arrows it could be fine.
        The unary - operator causes problems everywhere to be honest, I don't like it. There's no issue with 0-x.

        On top of that, making that not whitespace dependent is idiotic. Haskell has unary - but x <- y doesn't access it for obvious reasons and one needs x < -y]/code].

        Weirdly enough Haskell uses <- for non-assignment in do-notation.

        Most languages allow shadowing lets by the way which is mathematically fine. The x is a different x that shadows the former.

    • 2 months ago
      Anonymous

      No. Not only is it not mathematically correct, it also prevents us from using the equals sign for testing equality, forcing us to do strange stuff like ==. This has also led to security vulnerabilities, both unintentional and intentional: https://freedom-to-tinker.com/2013/10/09/the-linux-backdoor-attempt-of-2003/

      <- in many languages would cause problems, as does x<-1 refer to an assignment or whether x is less than -1? For some languages that already heavily use arrows it could be fine.

      [...]
      In mathematical descriptions of algorithms ":=" is used.

      [...]
      In a mathematical context "let" implies that the previous statements still hold, so something like:
      let x be 1
      let x be 2

      would be mathematically wrong.
      I have no problem with something like
      set x to 1
      set x to 2

      other than it being verbose.

      I think := is ideal in concise languages, and set or something similar is best in verbose languages.

  2. 2 months ago
    Anonymous

    yes, because it's the same in mathematics

    • 2 months ago
      Anonymous

      There is no assignment operator in mathematics because there is no memory to store a value. Equality is not the same as assignment.

      • 2 months ago
        Anonymous

        It is, they're just immutable

      • 2 months ago
        Anonymous

        f(x) = 2x.
        f(5) = 10.

      • 2 months ago
        Anonymous

        this

        f(x) = 2x.
        f(5) = 10.

        that's equality moron

      • 2 months ago
        Anonymous

        "let x be ____"
        sigma notation?

    • 2 months ago
      Anonymous

      In math there are extra symbols for definitions like ≡, ≝, and ≔.
      (screenshot in case IQfy strips the unicode symbols)

      • 2 months ago
        Anonymous

        definitions aren't assignments tough

        • 2 months ago
          Anonymous

          It's the closest thing math has to assignments.

      • 2 months ago
        Anonymous

        ≡ usually means equality under some equivalence relation, as in 1≡3 (mod 2) is the same as 1+2Z=3+2Z.
        In algorithm papers I've only seen :=.

  3. 2 months ago
    Anonymous

    Good morning.

    Was just thinking about this and a poop emoji for assignments would be kind of nice.

  4. 2 months ago
    Anonymous

    = for comparison
    := for assignment

    s= to set a variable if a condition was ever true
    r= to reset a variable if a condition was ever true

  5. 2 months ago
    Anonymous

    variable x = 1
    ...
    assign x = 2

    No ambiguity.
    The verbosity won't be a problem if you switch from text-based to frame-based editing.

    • 2 months ago
      Anonymous

      variable x = 1
      is literally an assignment

      • 2 months ago
        Anonymous

        It is an initial declaration (a new variable name introduced in the scope) + an assignment.

  6. 2 months ago
    Anonymous

    x is 5
    x is 1488
    y is x + 1
    add a b is a + b
    add x y
    seems good to me

  7. 2 months ago
    Anonymous

    colon

  8. 2 months ago
    Anonymous

    the software development industry needs a containment platform for functional programmers so they don't slow down productive engineers with their nonsense

  9. 2 months ago
    Anonymous

    They should use :=, but that is slower to type than =, so we'll just stick with =, thanks.

    • 2 months ago
      Anonymous

      go uses :=

      • 2 months ago
        Anonymous

        That's for declaring. Go still uses = for assignment.

  10. 2 months ago
    Anonymous

    Pascal had the right idea all along.

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *