Prolog Type incompatible

Visual Prolog 8 throws error c504: expression has type '() → :: char procedure', which is incompatible with type ':: char'.

main.pro

implement main
    open core, console

class predicates
     : ().
    print : ().

clauses
    ().

    print() :-
        console::initUtf8(),
        ,
        C = readChar,
        /*         C */
        write(C),
        C1 = convert(char, C),
        C2 = convert(char, '\r').
        C1 = C2.
        /*      ? fail,   */

    run() :-
        ,
        fail.

    run() :-
        succeed.
        % place your own code here

end implement main

goal
    mainExe::run(main::run).

How to fix it?

+4
source share
1 answer

You seem to have a bug here:

    print() :-
        ....
        ,
        C = readChar,       % <<-------

You should write like this:

        C = readChar(),

how the searchreadChar in the manual shows where you can see the proposed use as

_ = console :: readChar ().

It seems that the error message suggests the same thing: readChar"is a type procedure () -> char." Rather than "a char". Your C- char. To get the result from the procedure, we usually need to run it (this “start” is not related to runin your code).

+3
source

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


All Articles