09.12.2012 Views

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Other Literals<br />

For more arithmetic operations, mathematical functions, and bit-level operations, see one of the referenced<br />

texts.<br />

Smalltalk constants are called literals. Numbers, symbols, characters, strings, and arrays are all literals.<br />

A single character is prefaced by a dollar sign, <strong>for</strong> example<br />

$T<br />

Strings of characters are delimited by single quotes, <strong>for</strong> example,<br />

'this is a string'<br />

You can concatenate two strings by typing a comma between them, <strong>for</strong> example,<br />

'first half', 'second half'<br />

evaluates to the string<br />

'first half second half'<br />

A symbol is prefaced by a number sign and cannot include any internal blanks, <strong>for</strong> example,<br />

#thisIsASymbol<br />

You can create a symbol from a string by sending it the message asSymbol, <strong>for</strong> instance,<br />

'thisIsAString' asSymbol<br />

Two strings of the same characters are not necessarily the same object. However, two symbols with the<br />

same name are actually the same object. Each symbol is unique in the system.<br />

Arrays are enclosed within parentheses and prefaced by a number sign, as in<br />

#(3 5 6 #anArray).<br />

Each object within the array is interpreted as a literal, thus the contents of the array<br />

#(2 $+ 5 #anArray)<br />

would be the number<br />

2<br />

followed by the character<br />

$+<br />

the number<br />

5<br />

and the symbol<br />

#anArray<br />

Leading number and dollar signs are not required within an array literal. For instance, the array defined<br />

earlier could be equivalently written as<br />

#(2 + 5 anArray)<br />

Suppose you wanted to evaluate the expression 2 + 5 be<strong>for</strong>e putting it into the array and that anArray<br />

was actually a variable. <strong>The</strong>n you would need to create the array as in the following example:<br />

| anArray |<br />

anArray := #(a b c).<br />

anotherArray := Array with: 2 + 5 with: anArray.<br />

<strong>The</strong> value of anotherArray is<br />

#(7 (a b c))<br />

517

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!