Smalltalk Aaron Bloomfield CS 415 Fall 2005

advertisement

Smalltalk

Aaron Bloomfield

CS 415

Fall 2005

1

Evolution of Smalltalk

• Alan Kay – grad student at Utah

– Dynabook

• Xerox PARC.

• Influenced by Lisp, Simula, Ivan

Sutherland’s Sketchpad, LOGO, Dewey,

Montessori, Piaget

2

3

Smalltalk

• Interpreted

• Everything is an object

• Dynamically & Strongly Typed

• Rich programming environment

– Window-oriented display management

– Mouse, Menus

• Example of a pure Object-Oriented

Language

4

Smalltalk and Squeak

• Smalltalk – commercial product

• Squeak – free version, used for education

5

x <- 3 x <- x + 1

X is bound to 4

Bindings

In Squeak, write <as underscore OR

:=

6

Objects and Messages

• Everything is an Object

• Everything is done by sending messages to objects x * 2

• Sends the message *2 to the object x.

7

3 + 2 * 5

Other Examples

8

Inheritance

• Superclass

• Subclass

• Object

• Overriding

• No multiple Inheritance

9

Implementation

• Mostly written in Smalltalk

• Main loop: true whileTrue: [Display put: user run]

Class - userTask run ||

Keyboard read eval print

10

Virtual Machine

• Storage Manager

• Interpreter

• Primitive Subroutines

11

Storage Manager

• Collects and manages free space

• Handles requests to:

– Create new objects

– Fetch class of an object

– Fetch and store fields of an object

• Uses reference counting

12

Concurrency

• Easy to implement

• Handy for simulations

• Each activation record is a Smalltalk object sched map: [:Task | Task run]

13

Download