Literals
The usual string and numeric literals are supported.
"Some kinda something"
"The whole line.
"
3
2.75
0xDEADBEEF
Symbols are like strings, except that only one instance of a given symbol exists throughout the entire program. This means they can be compared for equality without looking at all the characters, and thus can take the place of enumerations.
'primary'
if alignment == 'justified'
switch alignment
'left'
'right'
'center'
'justified'
Character literals are specified using backquotes:
Finally, there are the following named literals:
Names
The value of a variable is accessed simply by giving its name:
args
current-line
point-1
It could be the name of a local variable, a function argument, a field, or a shared variable.
Note that names can contain hyphens (although they can't start or end with a hyphen). Underscores can also be used, but are heavily frowned upon. Hyphens are much less ugly and easier to type.
Operators
Most of the binary operators from C are available: +, -, *, /, %, |, &, ^. However, there are some subtle differences from the C precedence rules (see below). The || and && short-circuit operators are also available, as are the assignment operators (+=, -=, etc.).
There is a comma operator, but it's not used as it is in C. Instead, it is used to create "Tuples", which are essentially a form of array:
These unary operators are available: -, +, ~, !.
Message Sends
Sending a message to an object uses the normal Smalltalk syntax:
"Hello" length
point x
"Hello" substr: 3 length: 2
For functions in the current scope (that is, in the current namespace and its enclosing namespaces), you don't need to specify the receiver:
print-line
print-line: "Hello"
These would be message sends to the namespace prototype in which they are defined. For instance "print-line" would be the same as "Standard print-line".
"Super" sends are also available:
Precedence
Precedence is as follows:
=, +=, etc.
||
&&
!
keyword: send
,
|
^
&
==, !=
<, >, <=, >=
<<, >>
+, -
*, /, %
unary+, unary-, ~
unary send
primary
"Primaries" include literals, names by themselves, keyword sends with implicit receivers, and parenthesized expressions.