kosarev / zx

ZX Spectrum emulator written in a mix of Python and C++
https://twitter.com/z80tools
MIT License
21 stars 1 forks source link

Use exceptions for quitting from the emulation loop #10

Closed kosarev closed 4 years ago

kosarev commented 4 years ago

Using the done kind of flags is complicated because with several run() calls in place, e.g., a tape_load() followed by a regular run(), the caller side would need to take explicit measures to make sure the the runs in the middle did not terminate due to user actions, such as pressing ESC or F10. These extra checks are easy to forget and misimplement whereas with exceptions it looks like it would be pretty straightforward and natural.

Once done, the stop() function should merely raise that exception.

kosarev commented 4 years ago

Done in: 2c41499 [#10] Let exceptions to pass through emulator-run functions. 34f44cc [#10] Raise exception on stopping emulation. 72119d6 [#10] Introduce emulator-specific exceptions.