Dyalog / pynapl

Dyalog APL ←→ Python interface
MIT License
75 stars 12 forks source link

Refactor OS-dependant FIFOs to abstract away OS differences. #15

Open rodrigogiraoserrao opened 2 years ago

rodrigogiraoserrao commented 2 years ago

In IPC.py, we define a couple of classes to represent FIFOs. In particular, we implement a FIFO for Unix systems and another one for Windows systems. Then, the file ends with a global if statement that defines FIFO to be the appropriate class for the given operating system. This is a bit flaky.

Instead, we could look at how pathlib (from the standard library) implements Path, which dynamically figures out the OS it's in. (Plot twist: this is done through the dunder method __new__.)

In doing this, we should figure out what exactly is the protocol that we need from the FIFOs, so that we can implement that protocol for the two types of systems. When this is done properly, there will be no need to keep differentiating from the two types of FIFOs in the remainder of the code.