giovinazzo-kevin / Ergo

Other
4 stars 0 forks source link

Proper I/O #60

Closed giovinazzo-kevin closed 11 months ago

giovinazzo-kevin 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.

giovinazzo-kevin commented 1 year ago

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

giovinazzo-kevin 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.

giovinazzo-kevin commented 11 months ago

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