DOC PREVIEW
UW CSE 341 - Lecture Notes

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

'&$%CSE 341:Programming LanguagesDan GrossmanSpring 2004Lecture 19— Introduction to SmalltalkDan Grossman CSE341 Spring 2004, Lecture 19 1'&$%TodayWhy Smalltalk?Some basics of smalltalk programs• Syntax• Messages• Blocks• Classes and Methods• Dynamic Dispatch• self and superSection: The Squeak environment (projects, saving your work, etc.)Dan Grossman CSE341 Spring 2004, Lecture 19 2'&$%Smalltalk• Pure object-oriented• Class-based• Dynamically typedA good starting point for discussing what each of these means andwhat other languages look like.The language has been quite stable since 1980.Other points:• A tiny language; easy to learn almost all of it• A complete commitment to dynamic changes; little abstractionsupportDan Grossman CSE341 Spring 2004, Lecture 19 3'&$%Overview of Smalltalk1. All values are objects• Even numbers, code, and classes2. Objects communicate via messages (i.e., methods)3. Objects have their own state4. Every object is an instance of a class5. A class provides behavior for its instancesThis sounds a lot like Java, but smaller.It’s also much more like Scheme than it seems; we’ll return to “whatreally makes something OO”But first we need to get “the feel for Smalltalk”Dan Grossman CSE341 Spring 2004, Lecture 19 4'&$%Syntaxexp ::= atom | assign| unarySend | infixSend | keywordSend| ( exp ) | exp . exp | ^ expatom ::= ID | literal | blockliteral ::= INTEGER | STRING | ...block ::= [:ID1 ... :IDn | exp] | [ exp ]assign ::= name := exp | name _ expunarySend ::= exp IDinfixSend ::= exp OPERATOR expkeywordSend ::= exp ID1: exp ... IDn: expDan Grossman CSE341 Spring 2004, Lecture 19 5'&$%Some key ideas• Really, everything is an object• Blocks are lambdas• Return (↑) is special• Everything is “dynamic” – evaluation can add/remove classes,add/remove methods, etc.• Dynamic typing• Dynamic dispatch• Sends to self (a special identifier; Java’s this)Dan Grossman CSE341 Spring 2004, Lecture 19 6'&$%Protection?• Fields are inaccessible outside of instance• All classes and methods are available to everyone• No namespace management; category has no semantic significanceDan Grossman CSE341 Spring 2004, Lecture 19


View Full Document

UW CSE 341 - Lecture Notes

Documents in this Course
Macros

Macros

6 pages

Macros

Macros

6 pages

Macros

Macros

3 pages

Mutation

Mutation

10 pages

Macros

Macros

17 pages

Racket

Racket

25 pages

Scheme

Scheme

9 pages

Macros

Macros

6 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?