my_file.open(); // Error: this may fail.
1) If this can fail, then it should be a compile error to not test the result code.
2) IMHO it would be nice if there was something like Python's with statement to correctly close a file.
with open(filename, 'r') as f:
f.read()
# f.close() invoked automatically here
This prevents trying to close a file that is not opened.The idea of encoding a state machine into the types seems interesting.