I’m using: SWI-Prolog version 8.0.2.
I’ve been staring at the code below for a long time now and I can’t for the life of me figure out why SWI-Prolog is complaining that the else
section is unterminated, despite there clearly being an endif
statement present. If I remove the entire if/else/endif
block the error goes away.
Can someone see something that I’m just not seeing?
:- if(pengine_self(_)).
% This predicate calls pengine_output if we are in a Pengines context, otherwise
% write() is called.
x_write(Str) :-
% We are running in a Pengines instance, use pengine_out.
pengine_output(Str).
x_nl :-
% We are running in a Pengines instance, use pengine_out.
pengine_output('\n').
:- else.
x_write(Str) :-
% We are NOT running in a Pengines instance, use write.
!,
write(Str).
x_nl :-
% We are NOT running in a Pengines instance, use nl.
!,
nl.
:- endif.
UPDATE: Nevermind, I completely exited the interpreter and reloaded swipl
and the error disappeared. I’ll leave this post here in case someone else runs into the same problem, if no one objects to me doing that.