-
Book Overview & Buying
-
Table Of Contents
Building Programming Language Interpreters
By :
The last aspect that I wanted to include in this discussion about how values and containers affect language design is the way the language values model operations such as copying, referencing, and sharing values. To explore this topic, I want to go back to a comparison between C++ and Python.
In Python, the lifetime of a value is managed by the interpreter based on its usefulness. This means that the value remains in memory as long as at least one reference points to it, directly or indirectly. Once the interpreter determines that a value is no longer reachable from any part of the program, it automatically reclaims the memory occupied by that value.
The Python language is designed in a way where there is very little ambiguity about what happens when you assign an object to a different variable or insert it into an existing container. This is also where the immutability of some of the values in Python gives room for the interpreter to...