Object-Based LanguagesAbadi, M. & Cardelli, L. (1996). A Theory of Objects. New York, Springer. Chapter 4: "Object-Based Languages."CPSC 701.01 Object Theory |
Table of Contents | |
Ojbect-based Languages
|
OO Languages need not be based on
classes.
Object may be thought of as a more primitive concept than class:
|
4.3 Inheritance by Embedding and by Delegation | |||||||||||||||||
Inheritance
|
Object cloning + method update + object extension =
inheritance
(sort of...)
|
||||||||||||||||
Object Extension
|
Not so easy
|
||||||||||||||||
Obtaining
attributes
of donor
objects and
incorporating
attributes
|
Four* possible language types:
|
||||||||||||||||
Embedding vs
Delegation
|
Embedding and Delegation are just the same
principles as
we saw in class-based languages in section
2.1 (naive model) and section 2.3
(method
lookup).
|
4.7 Dynamic Inheritance and Mode-Switching | ||
Static Inheritance
|
Static delegation inheritance is when parent links are fixed (constant). | |
Dynamic Inheritance
|
Dynamic delegation inheritance is when parent links are allowed to be reassigned, which changes the behaviour of the host objects. | |
Dangerous Feature?
|
Dynamic inheritance can be considered very dangerous:
|
|
Elegant Feature: Mode
Switching
|
But constrained or disciplined dynamic
inheritance allows
some very elegant and useful features.
|
|
example
|
reparent reCellImp to cell'; |
|
Simulating Mode
Switching
|
Mode switching can be simulated without dynamic inheritance
using method
update:
reCellImp.get := reCellimp.set := |
4.8 Traits: From Prototypes back to Classes? | ||||||||
Traits
|
A trait is an object that typically only contains methods. | |||||||
Prototype
|
A prototype is an object that typically only contains fields and has a trait as a parent. | |||||||
Normal Objects
|
A normal object is an object that is cloned from a prototype and therefore shares its traits of its prototype. | |||||||
Roles
|
|
|||||||
Violation of
Prototyping!
|
Argument:
Prototypes aren't really true object because they aren't meant to be used. The idea or prototyping is that everything is an ordinary object. We are right back to the distinction that class-based languages make between objects and classes! |
|||||||
Continuum
|
The distinction between class-based and object-based
languages should
be thought of a continuum:
|
4.9 Types for Object-Based Languages | ||
Dynamic Features/
Static Type Systems
|
Dynamic features of object-based languages are
difficult
to capture with static type systems.
|
|
Typed
Object-Based
Languages
|
Appropriate type systems are just emerging:
|
|
up |
|||
Rob
Kremer
Last Modified Aug. 15, 2005 |
Graduate Course in Software Engineering |