Categories also provide runtime transparency. % with engines (and other components), we may start "assembling" some cars :- object(sedan,Ĭategories are independently compiled and thus allow importing objects to be updated by simple updating the imported categories without requiring object recompilation. Horsepower_rpm( HP, RPM) :- ^^horsepower_rpm( ClassicHP, ClassicRPM), % "super" call HP is truncate( ClassicHP * 1.23), % a souped up version of the previous engine :- category(sport, % a typical engine defined as a category :- category(classic, % a protocol describing engine characteristics :- protocol(carenginep). A simple object, defining a list member public predicate: A single source file can contain any number of entity definitions. Objects can be created dynamically but are usually static and defined in source files. Defining an objectĪn object encapsulates predicate declarations and definitions. An extends relation between two objects implies that both objects play the role of prototypes, with one of them extending the other, its parent prototype. For example, when an object instantiates another object, the first object plays the role of an instance and the second object plays the role of a class. Relations between entities define patterns of code reuse and the roles played by the entities. Logtalk provides objects, protocols, and categories as first-class entities. Some of the most important entity and predicate directives will be introduced in the next sections.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |