{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AdvTPL11 - Translation into P< Chapter 11 Translational...

Info icon This 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 11 Translational Semantics of Objects and Classes W. Pelz 2003-09 2 Translation into Λ P <: Works well for classes, but not subclasses Use expanded (not abbreviated) SOOL IVs are protected; methods are public Later work will include subclasses and hidden methods W. Pelz 2003-09 3 Representation of Objects Record of instance variables Pointer to methods appropriate to the object – more efficient than separate methods for each object In practice, methods access instance variables through an indirect mechanism More formally, we require each method to be parameterized by the record of IVs W. Pelz 2003-09 4 Translation of SOOL types to types in Λ P <: [203] Figure 11.1 Left-hand side are SOOL types Right-hand side are Λ P <: types • T C [| . |] [| . |] is the translation function W. Pelz 2003-09 5 W. Pelz 2003-09 6 Translation of CellIV and CellM CellIV = {|x: Integer|} RfCellIV = {|x: Ref Integer|} CellM = {| get: Void barb2right Integer; set: Integer barb2right Void; bump: Void barb2right Void|}
Image of page 1

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

View Full Document Right Arrow Icon
2 W. Pelz 2003-09 7 Translation of VisObjectType versus ObjectType • T C [| [|VisObjectType(CellIV ref , CellM) |] |] = VisObj(RFCellIV, CellM) which we have seen previously is of type RfCellIV × (RfCellIV barb2right CellM) • T C [| [|ObjectType CellM |] |] = Y.VisObj (Y, CellM) we know IVs exist ( Y), but no details W. Pelz 2003-09 8 closeobj closeobj Λ IVR. Λ M. λ(vo: IVR × (IVR barb2right M)) .pack IVR, vo as Y.Y × (Y barb2right M) (vo represents a visible object) Is a polymorphic function of type IVR. M.(IVR × (IVR barb2right M)) barb2right ( Y.(Y × (Y barb2right M))) W. Pelz 2003-09 9 Theorem 11.2.1 If S and T are types in SOOL such that C S <: T, then φ T C [| [|S |] |] <: T C [| [|T |] |] in Λ P <: Proof for most cases is trivial; a detailed proof for object types is given in the text W. Pelz 2003-09 10 Translation of Expressions [209] Figure 11.2 [211] Figure 11.3 Of special interest are translations involving bodies of functions, i.e., blocks, since new type and constant definitions are possible W. Pelz 2003-09 11 Translation of While If w = while E do { S } then we can write w = if E then { S; w } else { nop } W. Pelz 2003-09 12 Modeling Classes Use initial values of instance variables and methods to create the visible object Body of methods can refer to self which can
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern