What is the theory behind mutable and immutable types?

后端 未结 4 1023
甜味超标
甜味超标 2021-02-04 03:53

One of the things that I admire about Python is its distinction between mutable and immutable types. Having spent a while programming in c before coming to Python, I was astonis

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 04:26

    If you like the idea of immutability, you should check out a pure functional language. In Haskell all (pure) variables are immutable (yet still referred to as "variables", but there you go). It is a great idea - you and the compiler both know that passing something into a function cannot change it in any way.

提交回复
热议问题