4

Visual Prolog 8 throws error c504 : The expression has type '() -> ::char procedure', which is incompatible with the 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 can to fix it?

false
  • 10,264
  • 13
  • 101
  • 209
  • 1
    NB. with some googling I could find ["Visual Prolog 8 Language Reference"](http://wiki.visual-prolog.com/index.php?title=Visual_Prolog_8_Language_Reference) which seems related. – Will Ness Nov 05 '17 at 12:12
  • Did the error message tell you what line number the error occurs on? You should see a line with the error message like, `main.pro (x, y)` where `x` is the line and `y` is the character position. – lurker Nov 05 '17 at 12:44

1 Answers1

3

You seem to have the error here:

    print() :-
        ....
        цикл,
        C = readChar,       % <<-------

You should write it like this

        C = readChar(),

as searching for readChar in the manual reveals, where one can see the suggested usage as

_ = console::readChar().

Seem that the error message suggests the same: readChar "is a procedure of type () -> char.", not "a char". Your C is a char. To get the result from a procedure we usually need to run it (this "run" is unrelated to run in your code).

Will Ness
  • 70,110
  • 9
  • 98
  • 181