Slate's default support for character literals uses the $ symbol as a prefix. The following printable and non-printable characters require backslash escapes as follows:
Character name | Literal
Escape |
All other symbols can be immediately be preceded by $ in order to construct the Character object for them, for example,
$a, $3, $>, and $$
are all Character object literals for a, 3, >, and $, respectively.
Strings are comprised of any sequence of characters surrounded by single-quote characters. Strings can include the commenting character (double-quotes) without an escape. Embedded single-quotes can be provided by using the backslash character to escape them (\'). Slate's character literal syntax also embeds into string literals, omitting the $ prefix. All characters that require escapes in character literal syntax also require escapes when used within string literals, with the exception of double-quote marks and the addition of single-quote marks.
The following are all illustrative examples of Strings in Slate:
Symbols start with the pound sign character (#) and consist of all following characters up to the next non-escaped whitespace, unless the pound sign is followed exactly by a string literal, in which case the string's contents become the identifier for the symbol. So, for example, #@, #key:word:expression:, #something_with_underscores, and #'A full string with a \nnewline in it.' are all valid symbols and symbol literals.
A property of Symbols and their literals is that any literal with the same value as another also refers to the same instance as any other symbol literal with that value in a Slate system. This allows fast hashes and comparisons by identity rather than value hashes. In particular, as with Slate identifiers, a Symbol's value is case-sensitive, so #a and #A are distinct.
Internally, Slate currently keeps one global table for symbols, and uses individual context objects to hold local bindings.3
Arrays can be literally and recursively specified by curly-brace notation using stops as separators. Array indices in Slate are 0-based. So:
Immediate array syntax is provided as an alternative to create the array when the method is compiled, instead of creating a new array on each method invocation. The syntax is identical except that the first opening brace is preceded by the pound sign. The disadvantage is that no run-time values will be usable.