Visual Prolog 8抛出错误c504:表达式具有类型'() - > :: char procedure',它与类型':: 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).怎么解决呢?
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?
最满意答案
你似乎有错误:
print() :- .... цикл, C = readChar, % <<-------你应该这样写
C = readChar(),在手册中搜索readChar时,可以看到建议的用法
_ = console :: readChar()。
似乎错误消息暗示相同: readChar “是类型() -> char 。” ,而不是“一个char ” 。 你的C是个char 。 要从过程中获取结果,我们通常需要运行它(此“运行”与在代码中run无关)。
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).
更多推荐
发布评论