Open triska opened 6 years ago
Just a quick reply now. The pengines_io rebinds write/1, etc. to make nice Prolog terms. It does so by redefining these terms. There is not much choice: once you have a stream that contains a mixture of text and terms it gets hard. That is why it doesn't work for subodules. In addition the library rebinds the standard I/O streams to cacture output and forwards it to the client. That provides raw <pre>
output from modules that try to write.
This whole stuff is primarily there to make SWISH work. You best look at the swish source to see how it is deployed.
Let
server.pl
consist of the following code:This is very similar to the code in #37, except that the server now uses a further module, provided by the file
interaction.pl
with the following content:The intention here is that
format/2
in the submodule should also be rewritten (or reinterpreted) bypengines_io
, so that I get decorated output from the submodule without having to change the submodule's code.As a test case, I use
demo.html
:Please start the server with:
and then visit
http://localhost:5055/demo.html
.Judging from the JavaScript console,
main/0
is not affected by thepengines_io
declarations inserver.pl
.Is this the intended behaviour? If so, could you please explain how I can obtain decorated output in the submodule too? Thank you!