Discussions related to Visual Prolog
Gass
Posts: 16
Joined: 17 Aug 2017 8:51

Console main::run() ERROR

Unread post by Gass »

Code: Select all

class predicates     isSubSet : (T* CheckTerms, T* Terms) determ. clauses     isSubset([H], Terms) :-         list::isMember(H, Terms),         !.     isSubset([H | TT], Terms) :-         list::isMember(H, Terms),         isSubSet(TT, Terms).  run() :-         console::init(),         L1 = [1, 2, 3, 4, 5, 6],         L2 = [0, 3, 4, 5, 5],         list::all(L2, { (E) :- list::isMember(E, L1) }),         _ = stdIO::readchar().

main.pro(12,9)
error c631 : The predicate 'main::run/0', which is declared as 'procedure', is actually 'determ'
WHY??
Martin Meyer
VIP Member
Posts: 296
Joined: 14 Nov 2002 0:01

Re: Console main::run() ERROR

Unread post by Martin Meyer »

Because:

Right click in your source text on the predicate name all and select Go to/Go to Declaration. That takes you to the declaration of the list::all/2 predicate:

Code: Select all

predicates     all : (Elem* List, predicate_dt{Elem} Test) determ.
The predicate is declared to have predicate mode determ. That means it can either have none or one solution. In other words, it will either fail or succeed without a backtrack point to it.

By right clicking on run you can in same way go to the declaration of the main::run/0 predicate:

Code: Select all

predicates     run : runnable.
Continuing that trick you go to the declaration of predicate domain core::runable:

Code: Select all

domains     runnable = predicate.
Finally go to the declaration of core::predicate:

Code: Select all

domains     predicate = ().
The declaration of domain core::predicate states no predicate mode. Omitting of a predicate mode means that the default mode applies which is procedure. Mode procedure means that the predicate has exactly one solution. In other words, the predicate always succeeds without a backtrack point to it.

The compiler now complains about a contradiction: Your implementation of predicate main::run/0 can (according to declarations) fail because of the call to list::all/2, but main::run/0 is declared to succeed always. More precisely, the implementation you supplied for main::run/0 is of mode determ, while the declaration of main::run/0 requires an implementation of the stronger mode procedure.
Regards Martin
Post Reply