SlideShare a Scribd company logo
Classroom Object
Oriented Language:
COOL
S. M. M. Sadrnezhaad, R. Yazdanian, S. Karimi
Design goals
 Taught in compiler course in some universities
 Designed to be implementable in a short time (one semester)
 Give students an idea of many features of OO languages,
including:
 Abstraction
 Static Typing
 Inheritance
 Memory management
 Simple reflection
 Leaves many features out which are common to other languages
The not so COOL parts
 No arrays
 No floating point operations
 No “static” modifier
 No interfaces
 No method overloading
(but still allow overriding)
 No exceptions
 No packages
The reference compiler
 Built with C++
 Generates code for MIPS simulator named SPIM
Where does execution start?
 A class “Main” must be defined
 Containing a no-args “main” method
 Starts program execution
Expressions
 Expression language
 every expression has a type and a value
 Loops: while E loop E pool
 Conditionals: if E then E else E fi
 Case statement: case E of x: Type  E; esac
 Arithmetic operations
 Logical operations
 Assignment x  E
Basic structure and classes
 Basically, a COOL program is a set of classes
 Similar to Java
 Almost every type is a class (next slide)
 Blocks defined using { and }.
 Each COOL class has a set of features
 Methods
 No explicit return
 Attributes (variables)
Classes and types: continued
 Primitive types: Boolean, Int, String
 Built-in types: The above, + Null, Nothing, Unit, Any
 Every type except Null and Nothing is a class
 Int, Boolean, Unit cannot be superclass
 “Any” class is the root of class hierarchy
 Similar to “Object” in Java
 Each type “conforms” to ancestors
 “Nothing” conforms to all
 “Null” conforms to all but Int, Boolean, Unit
 Null and Nothing cannot be superclass (obviously)
Information hiding
 Attributes only accessed through methods of same class
(“Information hiding”)
 Methods are global (public)
 Getters and Setters necessary
 Example
class Point {
…
getx () : Int { x };
setx (newx : Int) : Int { x  newx };
};
18
Inheritance
 We can extend points to colored points using subclass (class
hierarchy)
class ColorPoint inherits Points {
color : Int  0;
movePoint(newx : Int, newy : Int) : Point {
{ color  0;
x  newx; y  newy;
self;
}
};
};
0 0
y color
*
movePoint
0
x
Classes: behind the scenes
 An instance of a class has pointer to method
 All instances of a class point to single instance of method
 Example:
0 0
x y
*
movePointmethods
The “new” command
 Explicit
class Main {
i : IO <- new IO;
main():Int {
i.out_string("Hello World!n"); 1; };
};
 Anonymous
class Main {
main():Object {
(new IO).out_string((new IO).in_string().concat("n"))};
};
Typing
 Static typing: Type defined at variable definition time
 Static type inferred at compile time for each expression
 Bottom-up
 Dynamic, exec time type may differ
 But dynamic type “conforms” to static type
 Errs on the conservative side
 Attributes of classes initialized
 Boolean: false, Unit: (), Int: 0
 Others: Null
Method invocation
 Dynamic type may differ from static
 Methods invoked instead of calling -> Late binding
 Invoked by dispatch
 Find class of the instance
 Find the method
 Eval args
 Bind the method and the object
 Run method
Memory Management: Environment
and Store
 Environment: Mapping of identifiers to locations
 i.e. symbol table
 Store: Where the values are stored -> Heap
 Looking up a variable’s value:
 Look its location up in environment
 Look up the value at location in store
 When new is invoked
 New env. and store created, new identifier added to them
 Dynamic allocation w/ Garbage Collector
Conclusion
 Object oriented
 Objects, virtual method calls, but no overloading
 Strongly typed
 Primitives for int, boolean, string
 Reference types
 Dynamic allocation and Garbage Collection
 Heap allocation, automatic deallocation
 Many things are left out
 short time implementation
Question time!
Thank you for (if) your attention! :)

More Related Content

PPTX
Error Detection and correction concepts in Data communication and networks
PPT
deadlock avoidance
DOCX
Anhnh osg202-1
PPTX
memory reference instruction
PPTX
Object Oriented Programming Using C++
PDF
8086 microprocessor lab manual
PDF
B TREE ( a to z concept ) in data structure or DBMS
PPTX
Chapter 4 Classification
Error Detection and correction concepts in Data communication and networks
deadlock avoidance
Anhnh osg202-1
memory reference instruction
Object Oriented Programming Using C++
8086 microprocessor lab manual
B TREE ( a to z concept ) in data structure or DBMS
Chapter 4 Classification

What's hot (20)

PPTX
UNIT 10. Files and file handling in C
PPT
DATA PERSISTENCE IN ANDROID OPERATING SYSTEM
PPTX
8051 MICROCONTROLLER ARCHITECTURE.pptx
PPTX
Logical and shift micro operations
PPT
Pointers C programming
PPTX
File Management in Operating System
PPT
Searching in c language
PPS
Computer instructions
PPTX
Distributed file system
PDF
Optimizing MapReduce Job performance
PPT
Data Mining: Concepts and techniques classification _chapter 9 :advanced methods
PPTX
9.bst(contd.) avl tree
PPT
Disk scheduling algorithms
PDF
Memory management
PPT
Unit-3_BDA.ppt
PPSX
File system security
PPT
Arithmetic & logical operations in 8051
PPTX
Hash table
PDF
Deadlock Avoidance - OS
DOCX
Test EEP IT question.docx
UNIT 10. Files and file handling in C
DATA PERSISTENCE IN ANDROID OPERATING SYSTEM
8051 MICROCONTROLLER ARCHITECTURE.pptx
Logical and shift micro operations
Pointers C programming
File Management in Operating System
Searching in c language
Computer instructions
Distributed file system
Optimizing MapReduce Job performance
Data Mining: Concepts and techniques classification _chapter 9 :advanced methods
9.bst(contd.) avl tree
Disk scheduling algorithms
Memory management
Unit-3_BDA.ppt
File system security
Arithmetic & logical operations in 8051
Hash table
Deadlock Avoidance - OS
Test EEP IT question.docx
Ad

Viewers also liked (20)

PPT
Classroom Object
PDF
Speaking class 7
PPT
Classroom objects
PPT
Classroom objects
PPT
Classroom
PPT
General Linguistics By Rabia
DOC
Classroom objects
PPTX
Classroom objects
PDF
1.8 my classroom
PDF
Classroom objects
PDF
Classroom Objects
DOC
Classrom Objects Worksheet
PPTX
Worksheet classroom objects
DOC
Classroom objects textbook page 73
PDF
Classroom Objects 5
PPTX
21st century teacher
PPSX
ESL: Classroom Objects
PPTX
CLASSROOM OBJECTS
PPSX
Classroom Objects: PowerPoint Activities
Classroom Object
Speaking class 7
Classroom objects
Classroom objects
Classroom
General Linguistics By Rabia
Classroom objects
Classroom objects
1.8 my classroom
Classroom objects
Classroom Objects
Classrom Objects Worksheet
Worksheet classroom objects
Classroom objects textbook page 73
Classroom Objects 5
21st century teacher
ESL: Classroom Objects
CLASSROOM OBJECTS
Classroom Objects: PowerPoint Activities
Ad

Similar to Classroom Object Oriented Language (COOL) (20)

PPT
Modern Compiler Design
PPT
Introduction to Java(basic understanding).ppt
PPT
Presentation to java
PPT
PPT
Introduction to csharp
PPT
Introduction to csharp
PPT
Introduction to csharp
PPT
Introduction To C#
PPT
Oop java
PDF
C# Summer course - Lecture 3
PPT
Intro to Java for C++ Developers
PPT
Internet programming slide - java.ppt
PPTX
PPT
Introduction toc sharp
PPT
IntroductionToCSharp.ppt
PPT
IntroductionToCSharppppppppppppppppppp.ppt
PPT
IntroductionToCSharp.ppt
PPT
IntroductionToCSharp.ppt
PDF
From Java to Python: beating the Stockholm syndrome
PPT
Core_java_ppt.ppt
Modern Compiler Design
Introduction to Java(basic understanding).ppt
Presentation to java
Introduction to csharp
Introduction to csharp
Introduction to csharp
Introduction To C#
Oop java
C# Summer course - Lecture 3
Intro to Java for C++ Developers
Internet programming slide - java.ppt
Introduction toc sharp
IntroductionToCSharp.ppt
IntroductionToCSharppppppppppppppppppp.ppt
IntroductionToCSharp.ppt
IntroductionToCSharp.ppt
From Java to Python: beating the Stockholm syndrome
Core_java_ppt.ppt

More from Masoud Sadrnezhaad (20)

PDF
Facade Design Pattern
PDF
Epistemic Justification
PDF
استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...
PDF
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...
PDF
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...
PDF
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...
PDF
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سرایی
PDF
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...
PDF
چارچوب توصیف منبع برای ذخیره و بازیابی معنا
PDF
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازمانده
PDF
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...
PDF
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانی
PDF
بی‌طرفی شبکه و ریشه‌های آن
PDF
Git Version Control System Part 2
PDF
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...
PDF
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)
PDF
معرفی و آموزش سامانهٔ مدیریت محتوا مزانین
PDF
Git Version Control System
PDF
نقش جامعه و دولت در حمایت از نرم‌افزار آزاد
PDF
بزرگ‌داده؛ مقیاسی از دنیای واقعی
Facade Design Pattern
Epistemic Justification
استفاده از داده‌های تجربی برای پشتیبانی از انتخاب فناوری در تصمیم‌گیری معماری...
تاریخچه و پیشینهٔ نظری اندازه‌گیری عملکرد و معرفی اجمالی برخی مدل‌های بلوغ و ...
تحلیل بده‌بستان‌ها میان ویژگی‌های کیفی برای پشتیبانی از تصمیم‌های معماری نرم‌...
سامانهٔ پشتیبان تصمیم برای شناسایی معماری‌های نامزد و اتخاذ تصمیم‌های معماری ...
آماده‌سازی ذهن برای خلاقیت و ابزار داستان‌سرایی
نمایش اجرای فرایندهای حرفه به کمک ابزارهای پویانمایی و شبیه‌سازی زمان و هزینه...
چارچوب توصیف منبع برای ذخیره و بازیابی معنا
حوزه‌های پژوهش در زمینهٔ مهندسی نرم‌افزار سامانه‌های خودتطبیق و خودسازمانده
معرفی و اجرای سناریوی SWIM در چارچوب Rainbow برای شبیه‌سازی معماری نرم‌افزار ...
معرفی و آموزش نحوهٔ استفاده از نرم‌افزار ERPNext برای برنامه‌ریزی منابع سازمانی
بی‌طرفی شبکه و ریشه‌های آن
Git Version Control System Part 2
از فرهنگ اجازه تا فرهنگ آزاد یا چگونه رسانه‌ها از تکنولوژی و قانون برای محدود...
طراحی و معماری خدمات ابری زیرساخت آمازون (AWS)
معرفی و آموزش سامانهٔ مدیریت محتوا مزانین
Git Version Control System
نقش جامعه و دولت در حمایت از نرم‌افزار آزاد
بزرگ‌داده؛ مقیاسی از دنیای واقعی

Recently uploaded (20)

PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Introduction to Artificial Intelligence
PDF
medical staffing services at VALiNTRY
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How Creative Agencies Leverage Project Management Software.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Introduction to Artificial Intelligence
medical staffing services at VALiNTRY
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
wealthsignaloriginal-com-DS-text-... (1).pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Reimagine Home Health with the Power of Agentic AI​
How to Migrate SBCGlobal Email to Yahoo Easily
Design an Analysis of Algorithms I-SECS-1021-03
Operating system designcfffgfgggggggvggggggggg
Wondershare Filmora 15 Crack With Activation Key [2025
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How Creative Agencies Leverage Project Management Software.pdf

Classroom Object Oriented Language (COOL)

  • 1. Classroom Object Oriented Language: COOL S. M. M. Sadrnezhaad, R. Yazdanian, S. Karimi
  • 2. Design goals  Taught in compiler course in some universities  Designed to be implementable in a short time (one semester)  Give students an idea of many features of OO languages, including:  Abstraction  Static Typing  Inheritance  Memory management  Simple reflection  Leaves many features out which are common to other languages
  • 3. The not so COOL parts  No arrays  No floating point operations  No “static” modifier  No interfaces  No method overloading (but still allow overriding)  No exceptions  No packages
  • 4. The reference compiler  Built with C++  Generates code for MIPS simulator named SPIM
  • 5. Where does execution start?  A class “Main” must be defined  Containing a no-args “main” method  Starts program execution
  • 6. Expressions  Expression language  every expression has a type and a value  Loops: while E loop E pool  Conditionals: if E then E else E fi  Case statement: case E of x: Type  E; esac  Arithmetic operations  Logical operations  Assignment x  E
  • 7. Basic structure and classes  Basically, a COOL program is a set of classes  Similar to Java  Almost every type is a class (next slide)  Blocks defined using { and }.  Each COOL class has a set of features  Methods  No explicit return  Attributes (variables)
  • 8. Classes and types: continued  Primitive types: Boolean, Int, String  Built-in types: The above, + Null, Nothing, Unit, Any  Every type except Null and Nothing is a class  Int, Boolean, Unit cannot be superclass  “Any” class is the root of class hierarchy  Similar to “Object” in Java  Each type “conforms” to ancestors  “Nothing” conforms to all  “Null” conforms to all but Int, Boolean, Unit  Null and Nothing cannot be superclass (obviously)
  • 9. Information hiding  Attributes only accessed through methods of same class (“Information hiding”)  Methods are global (public)  Getters and Setters necessary  Example class Point { … getx () : Int { x }; setx (newx : Int) : Int { x  newx }; };
  • 10. 18 Inheritance  We can extend points to colored points using subclass (class hierarchy) class ColorPoint inherits Points { color : Int  0; movePoint(newx : Int, newy : Int) : Point { { color  0; x  newx; y  newy; self; } }; }; 0 0 y color * movePoint 0 x
  • 11. Classes: behind the scenes  An instance of a class has pointer to method  All instances of a class point to single instance of method  Example: 0 0 x y * movePointmethods
  • 12. The “new” command  Explicit class Main { i : IO <- new IO; main():Int { i.out_string("Hello World!n"); 1; }; };  Anonymous class Main { main():Object { (new IO).out_string((new IO).in_string().concat("n"))}; };
  • 13. Typing  Static typing: Type defined at variable definition time  Static type inferred at compile time for each expression  Bottom-up  Dynamic, exec time type may differ  But dynamic type “conforms” to static type  Errs on the conservative side  Attributes of classes initialized  Boolean: false, Unit: (), Int: 0  Others: Null
  • 14. Method invocation  Dynamic type may differ from static  Methods invoked instead of calling -> Late binding  Invoked by dispatch  Find class of the instance  Find the method  Eval args  Bind the method and the object  Run method
  • 15. Memory Management: Environment and Store  Environment: Mapping of identifiers to locations  i.e. symbol table  Store: Where the values are stored -> Heap  Looking up a variable’s value:  Look its location up in environment  Look up the value at location in store  When new is invoked  New env. and store created, new identifier added to them  Dynamic allocation w/ Garbage Collector
  • 16. Conclusion  Object oriented  Objects, virtual method calls, but no overloading  Strongly typed  Primitives for int, boolean, string  Reference types  Dynamic allocation and Garbage Collection  Heap allocation, automatic deallocation  Many things are left out  short time implementation
  • 18. Thank you for (if) your attention! :)