by codegladiator · 7y ago · 0 comments
For a very small benefit of "automatic closing of resources" this looks like a huge trade-off.
And it's easy to determine when the use of the resource is complete: when there are no active pointers to the resource (the circular reference problem I don't think can happen with external resources like files).
with f = open("data.txt")
print f.readline()
The file is automatically closed at the end of the block. Those languages also have explicit open/close/seek calls to let the developer implement more complex cases.Btw, the os closes any open file when the program ends.