Re: instantiates & specializes keywords

Paulo Moura <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
On 15/jul/2004, at 21:48, Saurabh Bhatla wrote:

> hi all,
>    can anybody please explain mean how instantiates and specializes 
> work
> in logtalk. I am getting a hard time understanding the semantics of
> these two key words.

Logtalk objects encapsulate Prolog code. An object may be a stand-alone 
entity or be related to other objects. In object-oriented programming, 
there are two classes of systems: prototype-based systems and 
class-based systems. Logtalk supports both. In Logtalk, a hierarchy of 
prototypes is constructed using the "extends" relation. Class 
hierarchies use the "instantiates" and "specializes" relations. An 
"instantiates" relation means that an object is an instance of another 
object (it's class). A "specializes" relation means that an object 
(sub-class) is a specialization of another object (super-class). You 
may equate the notion of a class as corresponding to a set and the 
notion of instance as corresponding to an element of the set. These are 
basic notions of object-oriented programming which, as such, are 
explained on most books on the subject. These different relations 
("extends", "instantiates", and "specializes") imply different forms of 
code reuse. This means that, when a message is sent to an object, the 
lookup for the corresponding predicate declaration (in order to check 
if the message is valid) and the lookup for the predicate definition 
(in order to answer the message) depends on the possible relations of 
the object receiving the message with other objects. In the case of a 
prototype hierarchy, both lookups start on the object itself and then 
continue on the "extended" objects. In the case of an instance, the 
lookup for the predicate declaration starts in the instance class(es) 
and then continue in the class(es) super-class(es). The lookup for the 
predicate definition starts in the instance itself and then continues 
in the instance class(es) and then the class(es) suuper-class(es). A 
stand-alone object (i.e. an object that is not related to other 
objects) is always interpreted as a prototype. Please take a look at 
the Logtalk examples; "shapes" is a good one to learn the differences 
between prototype hierarchies and class hierarchies.

>     I know the questions are stupid but they are really confusing me.

There are no stupid questions when learning new subjects. Feel free to 
ask.

> Please explain them in simple language and not the language used in 
> user
> manual.

Note that the Logtalk documentation assumes that the reader already 
knows the basics of object-oriented programming and Prolog programming.

Best regards,

Paulo


P.S. This question is more appropriated for the Logtalk mailing list 
than for the GNU Prolog one.

-----------------------------------------------------------
Paulo Jorge Lopes de Moura
Dep. of Informatics                   Office 4.3  Ext. 3257
University of Beira Interior          Phone: +351 275319700
6201-001 Covilhã                      Fax:   +351 275319891
Portugal

<mailto:[email protected]>
<http://www.di.ubi.pt/~pmoura>     <http://www.logtalk.org>
-----------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.