Regular comment | " this is a comment " |
EOL-Comment (*) | "/ this is an End-of-Line comment |
Token-Comment (*) | "<<END
|
Integers | 12345 |
Large integers | 1234567890123456789012345... (arbitrary size) |
Integers with radix | 16rAFFE 0xFEED
* the 0x, 0b variants are extensions to standard Smalltalk |
Floats (IEEE double; roughly 17 decimals) |
12.456
|
Short floats (IEEE single; roughly 8 decimals) |
1.234f17
|
Long floats (IEEE quad; roughly 20 decimals) (*) |
1.234q17
|
Fractions |
(1/3)
|
ScaledDecimal |
123.456s2
|
Characters |
$a
Also: " null ", "tab ", "return ", "bell "...
|
Strings |
'hello' with C-escape sequences (*):
with embedded expressions (*):
internationalization (*):
regex (*):
|
Symbols |
#'hello' #foo (without quotes, if only alphaNumeric characters) |
Arrays |
#( el1 el2 ... elN )
each element being a literal constant for arrays within an array constant, the leading hash ("#") can be ommitted Notice: these are constants, allocated at compile time; (for arrays constructed at run time, see brace construct below) |
Byte arrays |
#[ b1 b2 ... bN ]
each byte-element being an integer constant in 0..255 |
Special number arrays (*) |
#XX( v1 v2 ... vN )
XX: is one of 'u8', 's8', 'u16', 's16', 'u32', 's32', 'u64', 's64', 'f32', 'f64' and each element being an integer or float constant |
Immediate Inline Objects (*) |
#{ foo: fooValue . bar: barValue }
fooValue and barValue: constant |
Without argument | [ expr1 . expr2 ... exprN ]
when evaluated (by sending it the "value" message), the value is the value from the last expression, exprN |
One argument | [:arg |
evaluate by sending it the "value:" message |
Multiple arguments | [:a1 :a2 ... :aN |
evaluate by sending it a "value:...value:" message |
Unary Expression (without argument) | receiver messageName
receiver is itself either a constant, a lambda-block, a unary expression or a parenthesized expression |
Keyword Expression: (1 arg) | receiver messageNamePart:argExpression
whitespace between the colon and the argExpression is optional. |
Keyword Expression: (any number of args) | receiver
|
Binary Expression | receiver binOP arg
with binOP being any combination of special characters: * , + , - , % , & , / , \ , | , = , < , > , ? and ,
|
Cascade Expression (sending multiple messages to the same receiver) |
receiver |
Parentheses for grouping | ( any expression )
|
Assignment | variable := expression can be used as expression. |
Computed Array (Brace Construct) | { expr1 . expr2 . ... . exprN }
instantiates a new Array object with elements from the expressions. |
Computed Inline Objects (*) |
{ foo: fooExpr . bar: barExpr }
fooExpr and barExpr are expressions. Notice the period to separate fields. |
Local variables (in block or method) | | var1 var2 ... varN |
variable declarations must be at the beginning, before any expression. |
Separating multiple expressions (sequence) | expr1 . expr2 . ... exprN
expressions (statements) are separated by fullstop (period) characters.
|
Return from method | ^ expression
returns from the enclosing method (also if inside a block-closure) |
Conditional Execution | boolExpr1 ifTrue:[ ... ] ifFalse:[ ... ]
variations without true part (ifFalse:), without false part (ifTrue:) and with the order reversed (ifFalse:ifTrue:) are available. |
While-Loop | [ boolExpr1 ] whileTrue:[ ... ]
notice the receiver being a block. |
For-Loop | start to:stop do:[:iterVar | ... ]
evaluates the lambda for each value in start..stop. |
Enumerating Collections | collection do:[:elementVar | ... ]
evaluates the lambda for each element in the collection. |
Evaluating a Lambda Block without arguments: with arguments: |
aBlock value
the number of arguments must match the number expected by the lambda (although varArg lambdas are also available) |
Starting a background thread | aBlock fork
evaluates the lambda in a separate thread. Alternatives are "forkNamed:" to give the thread a user friendly name. |
Logging and Messaging | Logger - redefinable logger (defaults to standard error)
Transcript - console window
Stdout - standard output
Stderr - standard error
Stdin - standard input
|
Numbers | Number (abstract superclass)
Integer (integral numbers),Float (inexact)
Fraction (exact)Complex a few more... |
Collections | Array (fixed size array)
OrderedCollection ,
List (variable size)
SortedCollection Set ,
Bag (unordered)
Dictionary (mapped collections)
BinaryTree ,
AVLTree SharedQueue (shared, synchronized)
many more... |
Process Handling | Process (lightweight thread)OSProcess (heavyweight OS process)
Semaphore , RecursionLock (synchronization)
Monitor , BoltLock Delay
|
Files & Streams | Filename (file naming, directory access, mime type)
Stream (basic stream framework)
ReadStream ,
WriteStream ,
EncodedStream ExternalStream , FileStream , Socket (OS streams)
|
Low Level Access | OperatingSystem (OS API calls)
Smalltalk (startup, shutdown and globals)
ObjectMemory (VM access)
|
-I | ignore snapshot image |
--quick | quick startup; no banner shown |
--repl | start an interactive read-eval-print-loop |
--print expr | eval expr, print its value then exit |
--eval expr | eval expr (without printing) then exit |
--execute filename | execute the script in fileName then exit |
--loadPackage package-ID | preload a compiled smalltalk class library (package) |
--help | show all other command line options |
Copyright © 2017-2020 Claus Gittinger, all rights reserved
<cg at exept.de>