DOC PREVIEW
UA CSC 520 - Study Notes

This preview shows page 1-2-3-25-26-27 out of 27 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 27 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 27 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 27 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 27 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 27 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 27 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 27 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

HistoryRunning SmalltalkSyntaxSyntax --- Unary MessagesSyntax --- Binary MessagesSyntax --- Keyword MessagesSyntax --- Order of EvaluationSyntax --- Cascading messagesSyntax --- BlocksReadings and References520—Spring 2005—48CSc 520Principles of ProgrammingLanguages48: OO Languages — SmallTalkChristian [email protected] of Computer ScienceUniversity of ArizonaCopyrightc 2005 Christian Collberg[1]520—Spring 2005—48HistoryDuring the 70’s Alan Kay worked on the Dynabook atXerox Parc. A lot like today’s laptops, with integratedtouch screen, sound, networking.Users would need some sort of programming skills tofully utilize the system. A language for non-experts wasneeded.Smalltalk borrows from Simula, Logo (a language forchildren), and Sketchpad (a constraint-based interactivedrawing system).Smalltalk was the first “pure” object-oriented language.Every interaction is through sending a message to anobject.[2]520—Spring 2005—48Running SmalltalkOn lectura, do the following:> cp /usr/local/lib/squeak/3.2-5/Squeak3.2-4956.* .> setenv SQUEAK_IMAGE $PWD/Squeak3.2-4956.image> /usr/local/lib/squeak/3.2-5/squeak[3]520—Spring 2005—48Squeak’s start screen:[4]520—Spring 2005—48Get rid of the crud:[5]520—Spring 2005—48Open the class browser:[6]520—Spring 2005—48Workspace lets you enter commands interactively.Transcript is “standard output.” do it executeshighlighted code.[7]520—Spring 2005—48Create a new category cc.[8]520—Spring 2005—48Create a new class MyClass. Select accept to add it.[9]520—Spring 2005—48Click on no messages to get a message template.[10]520—Spring 2005—48Create a method square. Select accept to add it.[11]520—Spring 2005—48Execute square.[12]520—Spring 2005—48SyntaxSquare brackets [...] contain code.Global items (variables, classes) begin with a capitalletter. Other items start with lowercase.Temporary variables: | x y z |.Assignment: ← or :=, or type as .Return value: ↑, type as ˆ.The dot (.) is the statement terminator.[13]520—Spring 2005—48Syntax — Unary MessagesA message M is sent to an object (receiver) R using thesyntaxR MA unary message has the syntaxR MFor example:D ← Dictionary new.[14]520—Spring 2005—48Syntax — Binary MessagesA binary message M to receiver R with argument A hasthe syntaxR M AFor example:8 + 9This sends the message + to the object 8 with theargument 9.[15]520—Spring 2005—48Syntax — Keyword MessagesA keyword message M to receiver R with argumentsA1, A2, A3, . . . has the syntaxR M1: A1M2: A2M3: A3...For example:DeannaTroi kiss: cheek how: tenderlyThis sends the message kiss:how: to the objectDeannaTroi with the arguments cheek andtenderly. In Java we would have written:DeannaTroi.kisshow(cheek,tenderly)[16]520—Spring 2005—48Syntax — Order of EvaluationMessages are executed from left to right.Parentheses can be used to force a particular order ofevaluation.Expressions are executed in the order1. unary messages,2. binary messages,3. keyword messagesBinary messages are executed left to right.[17]520—Spring 2005—48Syntax — Cascading messagesOften we want to send several messages M1, M2, . . . tothe same receiver. We can use the syntaxR M1:A1.R M2:A2.R M3:A3.Or, we can cascade the messages using a semicolon(;):R M1:A1; M2:A2; M3:A3...For example:Transcript show:5; cr; show:9; cr.[18]520—Spring 2005—48Syntax — BlocksA block is similar to a lambda expression. It’s syntax is:[arguments | code]Arguments are prefixed by a colon (:):[:x :y | ↑ x+y ][19]520—Spring 2005—48Collections: Dictionary.[20]520—Spring 2005—48Collections: Bag. 3 timesRepeat (from classInteger) sends the value: message to the blockargument 3 times.[21]520—Spring 2005—48expression timesRepeat block sends thevalue: message to block as long as expression istrue.[22]520—Spring 2005—48do: aBlock enumerates all the receivers elements.[23]520—Spring 2005—48ifTrue:ifFalse evaluates one of its blocksdepending on the value of the receiver.[24]520—Spring 2005—48[25]520—Spring 2005—48[26]520—Spring 2005—48Readings and ReferencesSqueak download: http://www.squeak.org/download/Squeak documentation:http://www.squeak.org/documentation/index.htmlSqueak manual:http://www.phaidros.com/DIGITALIS/englisch/sqk/sqk00002.htmhttp://www.cosc.canterbury.ac.nz/˜wolfgang/cosc205/smalltalk1.html#linkhttp://www.cosc.canterbury.ac.nz/˜wolfgang/cosc205/labs/labs98.htmlRead Scott: pp.


View Full Document

UA CSC 520 - Study Notes

Documents in this Course
Handout

Handout

13 pages

Semantics

Semantics

15 pages

Haskell

Haskell

15 pages

Recursion

Recursion

18 pages

Semantics

Semantics

12 pages

Scheme

Scheme

32 pages

Syllabus

Syllabus

40 pages

Haskell

Haskell

17 pages

Scheme

Scheme

27 pages

Scheme

Scheme

9 pages

TypeS

TypeS

13 pages

Scheme

Scheme

27 pages

Syllabus

Syllabus

10 pages

Types

Types

16 pages

FORTRAN

FORTRAN

10 pages

Load more
Download Study 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 Study 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 Study 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?