| |||||||||||
| Object oriented programming is useful to encapsulate internal state in predicates and manipulate the state. MINERVA allows to define classes and their methods. An object of a class has an internal state that can be accessed like blackboard data, i.e. using bb_* predicates. Example: :- class(counter). The MINERVA compiler processes these predicates and in addition generates predicates create_CLASS/1/2 to produce a new object. Resulting predicates are Object::Method(Arg1,..,ArgN)where Object must be produced with create_object/2 and Method must be an atom or compound. For the example above in classic Prolog: create_counter(10,Counter), Counter :: next(Index) For the example above with function notation: Counter <- create_counter(10), Index <- Counter::next, ...
| |||||||||||
| |||||||||||
| Back> |
|