OO in Parrot Dan Sugalski April 14, 2003.

Slides:



Advertisements
Similar presentations
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Advertisements

Python Objects and Classes
OBJECT ORIENTED PROGRAMMING (OOP) IN PYTHON David Moodie.
Parrot in a nutshell1 Parrot in a Nutshell Dan Sugalski
Language of the Month If it’s December, it must be Ruby! Adam Coffman and Brent Beer.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Squirrel Programming Language By Nandini Bhatta CS537 Summer 2008.
Subroutines. aka: user-defined functions, methods, procdures, sub-procedures, etc etc etc We’ll just say Subroutines. –“Functions” generally means built-in.
Taking JavaScript Seriously IS NOT THE WORST IDEA.
CSE333 SECTION 7. Midterm Debrief Hex View 1. Find a hex editor. 2. Learn ‘goto offset’ command. 3. See HW3 pictures. The header: Magic word Checksum.
Wolfgang Friebel, April AFS Administration Framework.
Learners Support Publications Pointers, Virtual Functions and Polymorphism.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
BASE CLASSES AND INHERITANCE CHAPTER 4. Engineer Class.
Inheritance Version 1.0. Topics Inheritance Constructors and Inheritance Hiding Methods and Variables Designing with Inheritance.
Parrot in detail1 Parrot in Detail Dan Sugalski
BIT 1003 – Presentation 7. Contents GENERATIONS OF LANGUAGES COMPILERS AND INTERPRETERS VIRTUAL MACHINES OBJECT-ORIENTED PROGRAMMING SCRIPTING LANGUAGES.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormack 3rd floor 607.
.NET Framework Danish Sami UG Lead.NetFoundry
Perl 6 Update - PGE and Pugs Dr. Patrick R. Michaud April 26, 2005.
1 Semantic Analysis Aaron Bloomfield CS 415 Fall 2005.
Inheritance Version 1.1. Topics Inheritance Constructors and Inheritance Function Over-riding (Redefinition) The Stringstream class Shadowing Variables.
Object-Oriented PHP (Chapter 6).
CAS Lightning Talk Jasig-Sakai 2012 Tuesday June 12th 2012 Atlanta, GA Andrew Petro - Unicon, Inc.
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Late binding and dynamic dispatch (Based on CSE 341 slides by Dan Grossman) 1.
Topic 11: Object-oriented Perl CSE3395 Perl Programming Camel3 chapter 12, pages perlobj, perltoot, perlbot, perlmod manpages.
C# F 1 CSC 298 Object Oriented Programming (Part 1)
An Introduction to Parrot Dan Sugalski January 28,2004.
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Programming in Java CSCI-2220 Object Oriented Programming.
CS536 Semantic Analysis Introduction with Emphasis on Name Analysis 1.
CS212: Object Oriented Analysis and Design Lecture 17: Virtual Functions.
Implementing an Interpreter Dan Sugalski
Operator Overloading: indexing Useful to create range-checked structures: class four_vect { double stor[4]; // private member, actual contents of vector.
What’s new in Perl 6 (The short form) Dan Sugalski
Object Oriented Programming COP3330 / CGS5409.  Inheritance  Assignment 5.
RUBY by Ryan Chase.
CS 598 Scripting Languages Design and Implementation 14. Self Compilers.
PerlNET: The Camel Talks.NET Jan Dubois The Perl Conference 6 San Diego, July 26 th 2002.
Copyright © 2005 Elsevier Object-Oriented Programming Control or PROCESS abstraction is a very old idea (subroutines!), though few languages provide it.
PHP vs. Python. Similarities are interpreted, high level languages with dynamic typing are Open Source are supported by large developer communities are.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
Review of Previous Classes Declaring Variables - var myVar:DataType = value Data Types – Number, uint, String, Boolean Functions – parameters, return.
Parrot in a nutshell1 Parrot in a Nutshell Dan Sugalski
CSE 130 : Winter 2009 Programming Languages Lecture 11: What’s in a Name ?
FEN 2014UCN Teknologi/act2learn1 Object-Oriented Programming “ The Three Pillars of OOP”: Encapsulation Inheritance Polymorphism The Substitution Principle.
Intro to Object Oriented Perl Packages, Modules, Classes.
Object-Oriented Programming “The Rest of the Story”, CS 4450 – Chapter 16.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Object Orientated Programming in Perl Simulated Models of Termites.
Programming in Perl references and objects Peter Verhás January 2002.
The heavyweight parts of lightweight languages LL1 Workshop November 17, 2001.
September 24th 2006, aKademy The Design and Implementation of KJSEmbed Richard Moore,
Context-Sensitive Analysis
Chapter 9 :: Data Abstraction and Object Orientation
The heavyweight parts of lightweight languages
The role of abstractions
For Example: User level quicksort program Three address code.
1.2 Key Concepts and Walkthroughs
Polymorphism CT1513.
Parrot in the Real World
Object Oriented System Design Class Diagrams
Design of the Parrot Virtual Machine The OO-ish bits
Keyword Arguments aka Named Parameters in Ruby (and Python)
Presentation transcript:

OO in Parrot Dan Sugalski April 14, 2003

Goals of Parrot OO Support perl 5’s “anything goes” style of objects Support perl 6’s “atrributes and compile- time fixednes” style of objects Support Ruby and Python objects All interchangeably

OO in four parts Outside code using objects Code within parrot-style object classes Class mutation Inheritance

Objects from the outside Objects are opaque They have properties You can call methods on them Other than that, don’t touch

Calling a method Perl 6 $obj.foo();

Calling a method Parrot Assembly clearall find_global P2, “$obj” set S0, “foo” callmeth

Calling a method Parrot Assembly (Fast version) clearall find_global P2, “$obj” set S0, “foo” callmeth.foo_hashed

Parrot class objects Objects are arrays of attributes One slot per attribute of the class and all compatible parent classes Most metadata about objects is stored in the class for the object. This includes slot directories and such

Mutating classes Adding attributes at runtime is possible We’re building a full notification and event system into Parrot Blows caches like mad, so try to avoid this

Inheritance You can inherit from any class Inheriting from ‘foreign’ classes does transparent delegation Delegated objects have parent properties for proper redispatch Opaque classes are a bit of a dead-end

New for Method Invocation Prototypes enforced for methods Method vs Sub invocation known Multimethod dispatch Guaranteed passed-in method names Method tail calls

Introspection No promises in general In practice, lots of opportunities Base object type is completely inspectable

Engine goodies Full notification and event system Method caching (lexically scoped!) Core hash calculations Multimethod dispatch handling Everything can be overridden

Really, everything Property fetching Property storing Returned property hashes Attribute get Attribute set can does isa AUTOLOAD Method lookup Method dispatch Pre and post method calling

Both kinds of objects Both reference and value types Objects have full control over their vtables Full control is yours if you want it Wraps up tying, overloading, and magic Oddly enough, all the object stuff is done as just a custom PMC class--no core changes were needed We’re making some anyway, though

Our plans for world domination Perl 6, Python, and Ruby objects all use the new scheme Transparent inheritance/delegation for perl 5 support