Skip to content

pengines_io does not affect submodules #38

@triska

Description

@triska

Let server.pl consist of the following code:

:- module(server, []).

:- use_module(library(pengines)).
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_server_files)).
:- use_module(library(http/http_files)).
:- use_module(library(http/http_unix_daemon)).

:- pengine_application(myapp).
:- use_module(myapp:library(pengines_io)).
pengines:prepare_module(Module, myapp, _Options) :-
        pengines_io:pengine_bind_io_to_html(Module).

:- use_module(myapp:interaction).


:- http_handler(/, http_reply_from_files(., []), [prefix]).

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:

:- module(interaction, [main/0]).

main :-
        format("hello!", []).

The intention here is that format/2 in the submodule should also be rewritten (or reinterpreted) by pengines_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:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Demo</title>
    <script src="js/pengines.js"></script>
  </head>
  <body style="padding-left: 5%; padding-right: 5%">
    <br><br>
    
    <script>
    var p = new Pengine({
        oncreate: function () { p.ask('main'); },
        onoutput: function () { console.log(this.data); },
        application: "myapp",
        server: "pengine",
    });

    </script>
  </body>
</html>

Please start the server with:

$ swipl server.pl --port=5055 --interactive

and then visit http://localhost:5055/demo.html.

Judging from the JavaScript console, main/0 is not affected by the pengines_io declarations in server.pl.

Is this the intended behaviour? If so, could you please explain how I can obtain decorated output in the submodule too? Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions