6 A Symbol is a name that is guaranteed to be unique. They can be used to represent
7 symbolic constant values, link::Classes/Dictionary:: keys, etc.
9 Symbols are represented syntactically as literals which are described in link::Reference/Literals::
11 subsection::Creating a Symbol
13 A symbol can be written by surrounding characters by single quotes (may include whitespace):
17 Or by a preceeding backslash (then it may not include whitespace):
21 A String can be converted into a symbol:
23 code::"arbeit".scramble.asSymbol;::
34 Answer whether the symbol can be a class name. This does not say if the class exists.
41 method::isMetaClassName
43 Answer whether the symbol can be meta class name. This does not say if the class exists.
46 \Meta_Array.isMetaClassName;
51 Answer whether the symbol has a trailing underscore.
57 method::isPrimitiveName
59 Answer whether the symbol is a valid primitive name
62 '_SymbolIsClassName'.isPrimitiveName;
65 subsection::Conversion
77 Answer the Class named by the receiver.
81 Return a symbol with a trailing underscore added.
85 Return a symbol with a trailing underscore removed.
89 return the ascii codes as an array
93 Convert to a ControlSpec
103 subsection::Environments
105 Symbols are used as keys to look up objects in dictionaries and environments, but also in arrays.
106 See link::Classes/IdentityDictionary::, link::Classes/Environment::, link::Classes/Event::
110 a.put(\commune, 1871);
116 put a value to the current environment using receiver as key
120 return a value from the current environment using receiver as key
130 Symbols respond to all unary and binary math operations by returning themselves. The result of any math operation between a Number or other math object and a Symbol is to return the Symbol. This allows for example operations on lists of notes which contain 'rest's to preserve the rests.
132 code::Pseq([1, 3, \rest, 2, 4] + 8);::
136 Use the symbol as a method selector and perform the message on firstArg, with args as arguments. This is used for mixing functions with method selectors (see also: Function).
139 '%'.applyTo(2553, 345);
140 ['+', '-', '*', { |a, b| a.rand + b.rand } ].choose.applyTo(2, 3);
144 subsection::Synthesis
146 Inside SynthDefs and UGen functions, symbols can be used to conventiently specify control inputs of different rates and with lags (see: NamedControl, ControlName, and Control).
151 Return a control rate NamedControl input with a default value (val), and if supplied, with a lag. If val is an array, the control will be multichannel.
154 a = { SinOsc.ar(\freq.kr(440, 1.2)) }.play;
157 a = { SinOsc.ar(\freq.kr([440, 460], 1.2)) }.play;
158 a.setn(\freq, [330, 367]);
164 Return an audio rate NamedControl input with a default value (val), and if supplied, with a lag. If val is an array, the control will be multichannel.
168 Return an intitalization rate NamedControl input with a default value (val). If val is an array, the control will be multichannel.
172 Return a TrigControl input with a default value (val). If val is an array, the control will be multichannel.
175 a = { Ringz.ar(T2A.ar(\trig.tr), \freq.kr(500, 1), 0.8) }.play;
176 a.set(\freq, 330, \trig, 1);
177 a.set(\freq, 830, \trig, 1);