AdvTPL10 - two versions of CellClass Chapter 10 SOOL, a...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 W. Pelz 2003-09 1 Chapter 10 SOOL, a Simple Object-Oriented Language W. Pelz 2003-09 2 two versions of CellClass class CellClass{ x : Integer = 0; function get ( ) : Integer is {return self.x} CellClass = class ( {| x: Ref Integer = ref 0; |}, {| get:Void Integer = function(v:Void): Integer is { return val self.x }; W. Pelz 2003-09 3 CellClass continued function set (nuVal:Integer): Void is { self.x := nuVal} function bump ( ): Void is{ self set (self get () + 1) } } set:Integer Command = function(nuVal:Integer): Command is { self.x :=nuVal ; return nop }; bump:Void Command = function(v:Void):Command is { self set(self get()+1) ; return nop} |} ) W. Pelz 2003-09 4 comments • distinguishes between functions and procedures • explicit l-values, r-values, and dereferencing • explicit lists (records) of instance variables and methods for easier type checking W. Pelz 2003-09 5 type syntax Defn. 10.2.1: The set, TYPE SOOL (TC, L, TI) of type expressions of SOOL for type constants C TC , record labels l i L , and type identifiers T,T i TYPE SOOL (TC, L, TI) is given by the CFG T Type ::= C | t | T 1 × × T n T n+1 | Ref T | ObjectType RT | VisObjectType(RT i , RT m ) | ClassType(RT i , RT m ) RT Rtype ::= {| l 1 :T 1 ; … ; l n :T n |} W. Pelz 2003-09 6 self • The keyword self must have a type. Since it provides access to both IV and M, the type “ObjectType RT” is not sufficient; it only refers to the methods • Type “VisObjectType(RT i , RT m )” has the required visibility
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 W. Pelz 2003-09 7 Defn. 10.2.2: grammar of SOOL Prog ::= Program id; Blk. Blk
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2011 for the course CS 542 taught by Professor Dr. thomas during the Spring '10 term at SUNY Buffalo.

Page1 / 4

AdvTPL10 - two versions of CellClass Chapter 10 SOOL, a...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online