Introduction
Allowable characters
a-z
, A-Z
, 0-9
, .+/\*~<>@%|&?
, blank
, tab
, cr
, ff
, lf
Variables
- Variables must be declared before use
- Shared vars must begin with uppercase
- Local vars must begin with lowercase
- Reserved names:
nil
, true
, false
, self
, super
and Smalltalk
Variable scope
- Global: defined in Dictionary Smalltalk and accessible by all objects in system
- Special: (reserved)
Smalltalk
, super
, self
, true
, false
and nil
- Method Temporary: local to a method
- Block Temporary: local to a block
- Pool: variables in a
Dictionary
object - Method Parameters: automatic local vars created as a result of message call with params
- Block Parameters: automatic local vars created as a result of value: message call
- Class: shared with all instances of one class & its subclasses
- Class Instance: unique to each instance of a class
- Instance Variables: unique to each instance
Syntax
- Comments are enclosed in quotes (
"
) - Period (
.
) is the statement seperator
Transcript
Assignment
Constants
Booleans
Arithmetic expressions
Bitwise Manipulation
Conversion
Blocks
- Blocks are objects and may be assigned to a variable
- Value is last expression evaluated unless explicit return
- Blocks may be nested
- Specification
[ arguments | | localvars | expressions ]
- Squeak does not currently support localvars in blocks
- Max of three arguments allowed
^
expression terminates block & method (exits all nested blocks) - Blocks intended for long term storage should not contain
^
Method calls
- Unary methods are messages with no arguments
- Binary methods
- Keyword methods are messages with selectors including colons
Standard categories/protocols
initialize-release
(methods called for new instance) accessing
(get/set methods) testing
(boolean tests - is) comparing
(boolean tests with parameter displaying
(gui related methods) printing
(methods for printing) updating
(receive notification of changes) private
(methods private to class) instance-creation
(class methods for creating instance)
Conditional Statements
Iteration statements
Character
Symbol
String
Array
Array
: Fixed length collection ByteArray
: Array limited to byte elements (0-255) WordArray
: Array limited to word elements (0-2^32)
OrderedCollection
Acts like an expandable array
SortedCollection
Like OrderedCollection except order of elements determined by sorting criteria
Bag
Like OrderedCollection except elements are in no particular order
Sets
Set
: like Bag
except duplicates not allowed IdentitySet
: uses identity test (==
rather than =
)
Interval
Associations
Dictionaries
Dictionary
IdentityDictionary
: uses identity test (==
rather than =
)
Internal Stream
FileStream
Date
Time
Point
Rectangle
Pen
Dynamic Message Calling/Compiling
Debugging
Misc