Expressions

Literals

The usual string and numeric literals are supported.

"Some kinda something" "The whole line.\n" 3 2.75 [Not yet supported.] 0xDEADBEEF [Not yet supported.]

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:

if cur-char == `\n` #...

Finally, there are the following named literals:

true false nil
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: +, -, *, /, %, |, &, ^. The usual (that is, C-style) rules of precedence apply. 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:

( "one", "two", "three" )

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 # "ll"

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".