-
Book Overview & Buying
-
Table Of Contents
Building Programming Language Interpreters
By :
It is common for the conversations around the implementation of an algorithm in an imperative language to talk about variables and values interchangeably. The distinction between these terms often doesn’t make a significant impact on the reasoning of the code, particularly in languages with simpler semantics.
The Python language, for instance, has a simple model where variables just point to values, and the lifetime of those values is defined by whether they are reachable, directly or indirectly, through existing variables.
Some values, such as numbers and strings, are immutable. Other values, such as objects, lists, and dictionaries, are mutable. The distinction is made even clearer by the fact that the operations in the language are designed with that principle in mind.
Assigning a different value to a variable just means the old value is no longer reachable in that particular way since it now points to the new value. There are no special...