SWI-Prolog - Unable to Confirm

I define the operator as follows:

:- op(500, xfx, =>). 

When I try something like:

 assert(a => b). 

The error message 'There is no permission to change static_procedure (=>) / 2' appears in Prolog.

Any solution?

+6
source share
2 answers

As a safety precaution, you should warn SWI that you are about to change the predicate at runtime:

 :- dynamic (=>)/2. 

placed at the top of the file should do this.

+6
source

Instead of (=>)/2 you should have designated a different character. Probably (->)/2 , which is a control construct that cannot be changed.

  Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 6.1.3-116-gf1c7e06)
 ...
 ? - asserta ((a -> b)).
 ERROR: asserta / 1: No permission to modify static procedure `(->) / 2 '
 ERROR: Defined at /opt/gupu/pl-devel/lib/swipl-6.1.3/boot/init.pl:194
 ? - op (500, xfx, =>).
 true

 ? - asserta (a => b).
 true
+5
source

Source: https://habr.com/ru/post/913938/


All Articles