object expressions
Posted: 2 Aug 2021 14:00
Hello
I just started to study object expressions.
I try to get the first example test1() working. https://wiki.visual-prolog.com/index.ph ... s#Examples
This is my code:
There is something I do not understand, I think, because I get the following error from the compiler.
What causes my problem?
Kind greetings
Ben
I just started to study object expressions.
I try to get the first example test1() working. https://wiki.visual-prolog.com/index.ph ... s#Examples
This is my code:
Code: Select all
namespace objectExpressions
interface iterator
open core
predicates
hasNext : () determ.
next : () -> integer.
end interface iterator
Code: Select all
namespace objectExpressions
class iterator : iterator
open core
predicates
test1 : ().
end class iterator
Code: Select all
namespace objectExpressions
implement iterator
open core
class predicates
writeAll : (iterator It).
clauses
writeAll(It) :-
if It:hasNext() then
stdio::writef("%\n", It:next()),
writeAll(It)
else
stdio::write("<<<end>>>\n")
end if.
clauses
test1() :-
It =
implement : iterator
hasNext() :-
fail.
next() = _ :-
exception::raise_error().
end implement,
writeAll(It).
Code: Select all
Type Action Description Filename Path
e263 No clauses for the predicate 'hasNext/0' in the class 'objectExpressions\iterator' iterator.pro objectExpressions\
s263 No clauses for the predicate 'hasNext/0' in the class 'objectExpressions\iterator' iterator.i objectExpressions\
e263 No clauses for the predicate 'next/0->' in the class 'objectExpressions\iterator' iterator.pro objectExpressions\
s263 No clauses for the predicate 'next/0->' in the class 'objectExpressions\iterator' iterator.i objectExpressions\
Kind greetings
Ben