Should programming languages continue to use equals sign for assignment?

Should programming languages continue to use equals sign for assignment?

Homeless People Are Sexy Shirt $21.68

DMT Has Friends For Me Shirt $21.68

Homeless People Are Sexy Shirt $21.68

  1. 1 month ago
    Anonymous

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

    • 1 month ago
      Anonymous

      Hieroglyph D53

    • 1 month 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.

      • 1 month 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.

      • 1 month 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

        • 1 month ago
          Anonymous

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

          • 1 month 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.

          • 1 month ago
            Anonymous

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

          • 1 month 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).

          • 1 month 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.

      • 1 month ago
        Anonymous

        Programming is not mathematics so it doesn't matter.

      • 1 month 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.

    • 1 month 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. 1 month ago
    Anonymous

    yes, because it's the same in mathematics

    • 1 month 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.

      • 1 month ago
        Anonymous

        It is, they're just immutable

      • 1 month ago
        Anonymous

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

      • 1 month ago
        Anonymous

        this

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

        that's equality moron

      • 1 month ago
        Anonymous

        "let x be ____"
        sigma notation?

    • 1 month ago
      Anonymous

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

      • 1 month ago
        Anonymous

        definitions aren't assignments tough

        • 1 month ago
          Anonymous

          It's the closest thing math has to assignments.

      • 1 month 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. 1 month ago
    Anonymous

    Good morning.

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

  4. 1 month 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. 1 month 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.

    • 1 month ago
      Anonymous

      variable x = 1
      is literally an assignment

      • 1 month ago
        Anonymous

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

  6. 1 month 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. 1 month ago
    Anonymous

    colon

  8. 1 month 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. 1 month ago
    Anonymous

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

    • 1 month ago
      Anonymous

      go uses :=

      • 1 month ago
        Anonymous

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

  10. 1 month ago
    Anonymous

    Pascal had the right idea all along.

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