200 likes | 289 Views
The Design of Class Mechanism for MOBY. Earlier Software designers have to choose between the following schemes for the development Class rich languages like C++ or JAVA. Module rich languages like Standard ML. Paper describes the design of the class mechanism with a richer module system
E N D
Earlier Software designers have to choose between the following schemes for the development • Class rich languages like C++ or JAVA. • Module rich languages like Standard ML.
Paper describes the design of the class mechanism with a richer module system • C++ and JAVA has the rich class mechanisms but week module system • Standard ML has rich Module System but lack Class Mechanism • Moby provides both rich Class and Module Mechanism
Class in the class mechanism has two roles: • Implementing Objects • Supporting inheritance • Based on the above roles class have two type of Clients: • Object Client • Class Client
MOBY : It is a ML-like language that supports Class bases mechanisms. MOBY has three mechanism to cover the features of class based languages. • Objects and Object Types. • Classes and Class Interfaces. • Modules and Module Signature.
Objects Object in MOBY are collection of fields and methods. Member of Objects: fields + Methods Operations on Objects: • Select a field • Update a field • Invoke a method
Object Type Object Type specifies which object members client may use. Object Types are nothing but are interfaces of JAVA.
Objtype Point{ meth getX : Uint->Int meth move:Int ->Point } Objtype CPoint extends Point with { meth getC : Uint->Color meth shade:Color ->CPoint }
Typing Typing in the MOBY is structural rather than Name Subtyping as in JAVA. Structural Subtyping has several variants: • Width Subtyping • Depth Subtyping • Full Subtyping
Modules • Modules in Moby are like ML-Style languages. • Signature Controls the Visibility of the definitions outside the Modules. • Modules may be nested . • Partial type revelation can be defined in signatures. type type-name <: type
Module PointTypes:{ objtype Point{ meth getX : Uint->Int meth move : Int ->Point } Type CPoint <: Point }{ ………body of the PointTypes }
MOBY Class • Defines the implementation of object • It contains the declaration of: • fields • Method • Makers (which are constructors in C++ or JAVA)
Class interface • It is a signature of the class • It is not interfaces as in JAVA. • It defines both object and class view.
Visibility • Internal Class View • External Class View • Internal Object View • External Object View
Class based features are realized inMOBY: • Static Class Members MOBY relies on Module system to support global definition. • C++ private inheritance : In MOBY Object Type implemented by subclass is independent of the Object Type implemented by its super class.
JAVA’s interfaces and C++’s multiple inheritance with abstract base classes: MOBY has the Structural sub typing relationship. • Final Classes: We can have this by hiding the class in a module and controlling the visibility of its methods . • C++ friends and JAVA’s package scope: MOBY uses the combination of modules and partial type revelation