Object oriented programming is useful to ...
Move to
Next Prev
Up Top
See also
Invocation
Predicates
Directives
Arithmetic
Functions
Objects
Error Messages
File Names
main
Packages
Debugger
Internationalization
Gui Programming
MINERVA to Java Interface
Java to MINERVA Interface
Restrictions
IF Computer > MINERVA > Manual > Reference > Objects

Objects

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).

Counter :: init :- bb_put(Counter, index, 0).

Counter :: init(InitialValue) :- bb_put(Counter, index, InitialValue).

Counter :: get(Value) :- bb_get(Counter, index, Value).

Counter :: set(Value) :- bb_put(Counter, index, Value).

Counter :: next(Value) :- Counter :: get(OldValue), NewValue is OldValue + 1, Counter :: set(NewValue), Value = NewValue.

:- endclass.

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,
	...

read on...
MINERVA
ifcomputer logo
f
Expert Services on the Web
Language
English
Japanese
Server
USA
Japan
Site Access
Local Index
Local Contents
Site Contents
Site Index
Printer Friendly
For imode
For PDA
Search
document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Objects/home_en.html
published 2008/6/30 update 2003/2/26 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 info@ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
scroll to top managed with ubiCMS