swi prolog version: version 9.3.19-13-gc4848cb0b-DIRTY
normally this works:
$ swipl
reading ~/.swiplrc (FS)
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.19-13-gc4848cb0b-DIRTY)
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).
(ins)?-
% halt
(halt by ^D)
But when I import pac, then I run into problems:
(ins)?- use_module( library( pac)).
true.
(ins)?- % ^D here
ERROR: Unknown procedure: end_of_file/0 (DWIM could not correct goal)
How about to disable pac query expansion by disable_pac_query/0,
which is all what I could propose for now.
% swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.19-18-gb55bb91c4)
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).
102 ?- use_module(library(pac)).
true.
?- disable_pac_query.
true.
?- ^D
% halt
%
Probably it is related to the following codes about pac query expansion,
which I borrowed without knowing exactly what '$current_typein_module'(C) does.
In terminal, ^D works for halt. However, in Ediprolog mode in Emacs, ^D works like Delete one character forward. I think I should give up to control ^D due to my little knowledge. Thanks for letting me to learn that ^D means something like end_of_file.
It depends. On windows terminal you use ^Z to
generate a end of file into the input stream.
The predcate get_code/1 will return -1. The
predicate read_term/2 will return end_of_file.
The top-level uses read_term/2 I guess.
Expanding end_of_file to halt is not a good idea.
Because the interpretation of end_of_file is
context dependent. During [user] it means
that nor more clauses are consulted, just like here:
Disclaimer: I don’t know whether pac supports [user] ?
(I don’t know exactly what your expand_query/3 does; but I presume it’s just a transformation of the input, so you don’t want to execute a halt but instead want to leave end_of_file as-is.)
Agree.
One of purpose of expand_query is to run queries which use my macro like this (zip).
% ?- maplist(pred([X,Y,X-Y]), [a,b],[1,2], Z).
%@ Z = [a-1, b-2].
Sometime it is convenient particularly in ediprolog mode when I’m in a hurry to run queries for testing, though I think one should not invent private macros so freely.