SWI-Prolog / packages-http

The SWI-Prolog HTTP server and client libraries
23 stars 23 forks source link

Meta-predicates not exported in html_write.pl #150

Open rrooij opened 2 years ago

rrooij commented 2 years ago

Certain meta-predicates like page/4 are defined in html_write.pl and used elsewhere (for instance, in http_header.pl). They are explicitly imported in http_head but not exported in html_write.

This results in socket connection errors when you run in a server in SWI Prolog with autoloading disabled:

ERROR: [Thread httpd@6363_4] http_header:status_page_hook/3: Unknown procedure: http_header:page/4
JanWielemaker commented 2 years ago

!? From html_write.pl:

:- module(html_write,
          [ reply_html_page/2,          % :Head, :Body
            reply_html_page/3,          % +Style, :Head, :Body

                                        % Basic output routines
            page//1,                    % :Content
            page//2,                    % :Head, :Body
            ...

In html_header.pl:

:- autoload(html_write,
        [ print_html/2, print_html/1, page/4, html/3,
          html_print_length/2
        ]).

page//2 is the same as page/4. Ok, it would be more elegant to use page//2 consistently but that is detail. The imports are generated automatically and this code doesn't yet handle DCGs separately.

Note that autoload/2 is interpreted as use_module/2 if autoloading is disabled.

rrooij commented 2 years ago

Thanks for explaining this. I didn't know about the two slashes. :smile:

The error still remains a mystery though! I'm trying to make a reproducible small example.