Setting Prolog flag "double_quotes" temporarily to "codes" causes help/1 to become confused

In freshly started REPL:

Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.24-33-g95b540cb9)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- set_prolog_flag(double_quotes,codes).
true.

Now I want to read the man page:

?- help(current_prolog_flag).
ERROR: Type error: `atom' expected, found `[69,110,118,105,114,111,110,109,101,110,116,32,67,111,110,116,114,111,108,32,40,80,114,111,108,111,103,32,102,108,97,103,115,41]' (a list)
ERROR: In:
ERROR:   [11] notrace(help_no_trace(current_prolog_flag))
ERROR:   [10] prolog_help:help(current_prolog_flag) at /usr/local/logic/swipl/lib/swipl/library/help.pl:136
ERROR:    [9] <user>

Ok, this is not impossible, maybe I can go back

?- set_prolog_flag(double_quotes,string).
true.

?- help(current_prolog_flag).
ERROR: Type error: `atom' expected, found `[69,110,118,105,114,111,110,109,101,110,116,32,67,111,110,116,114,111,108,32,40,80,114,111,108,111,103,32,102,108,97,103,115,41]' (a list)
ERROR: In:
ERROR:   [11] notrace(help_no_trace(current_prolog_flag))
ERROR:    [9] <user>
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.

There is some persistence. Probably cached content that get mangled via the reader?

Not a big problem, but still…

You cannot go back as the hep code was already compiled with the wrong flag setting. You will get no error if you do instead:

?- help(current_prolog_flag).
true.

?- set_prolog_flag(double_quotes,codes).
true.

?- help(current_prolog_flag).
true.

In SWI-Prolog, the double_quotes flag is local to a module and thus it’s possible that this issue is just a missing set_prolog_flag/2 directive in one of the help modules.

3 Likes

Yip. As far as I recall though, the library modules should inherit the setting from system and not from user and should thus not be affected.

Still, playing around with these global flags typically causes trouble and one should limit that to a module or compatibility work-around. That is notably the case for flags that manage syntax.

edit The modules were not affected as it should, but reading the manual index was affected. Now reads the file using the syntax from the library(pldoc/an_index) module which fixes this.

1 Like