G3Kappa / Ergo

Other
4 stars 0 forks source link

Proper I/O #60

Closed G3Kappa closed 6 months ago

G3Kappa commented 1 year ago

https://www.swi-prolog.org/pldoc/man?section=IO

Merging Ergo with Fiero has uncovered a serious refactoring urge: the Shell needs to be decoupled from the OS's standard streams.

All write and read predicates should be tweaked to work on streams and an equivalent to set_prolog_IO/3 should be introduced.

G3Kappa commented 1 year ago

https://www.swi-prolog.org/pldoc/man?section=streamalias

G3Kappa commented 1 year ago

A good 80% of the work is done.

Input and output streams can be redirected at the Facade level, and then individually at the Console and Solver levels. Error streams are not being used for the moment but they are correctly set up.

Predicates that read and write now do so from the relevant streams.

A new interface, IInputReader, has been added to provide GetKey functionality. The default implementation, ConsoleInputReader, defaults to Console.ReadKey and is suitable for the main shell.

TODO: Further decouple System.Console from Ergo Shell, creating an intermediate IConsole interface, represent streams as Ergo objects.

G3Kappa commented 6 months ago

Closing for now, since the current pipes work fine. Further work is warranted but not necessary