1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.54">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 19.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
14 span
.Apple-tab-span
{white-space:pre
}
18 <p class=
"p1"><b>Objects, Messages
</b></p>
19 <p class=
"p2"><br></p>
20 <p class=
"p3"><span class=
"Apple-tab-span"> </span>The SuperCollider language is an object oriented language. All entities in the language
</p>
21 <p class=
"p3">are objects. An
<b>object
</b> is something that has data, representing the object's state, and a set of operations that can be performed on the object. All objects are
<b>instances
</b> of some
<b>class
</b> which describes the structure of the object and its operations. Objects in SuperCollider include numbers, character strings, object collections, unit generators, wave samples, points, rectangles, graphical windows, graphical buttons, sliders and much more.
</p>
22 <p class=
"p2"><br></p>
23 <p class=
"p3"><span class=
"Apple-tab-span"> </span>Operations upon objects are invoked by messages. A
<b>message
</b> is a request for an object, called the
<b>receiver
</b>, to perform one of its operations. The means by which the operation is performed is determined
</p>
24 <p class=
"p3">by the object's class. Objects of different classes may implement the same message in different ways, each appropriate to the class of the object. For example all objects understand the 'value' message. Many objects simply return themselves in response to 'value', but other objects such as functions and streams first evaluate themselves and return the result of that evaluation. The ability for different objects to react differently to the same message is known as
<b>polymorphism
</b> and is perhaps the most important concept in object oriented programming since it allows the object's behaviour to be abstract from the point of view of the user of the object (the client).
<span class=
"Apple-converted-space"> </span></p>
25 <p class=
"p2"><br></p>
26 <p class=
"p3"><span class=
"Apple-tab-span"> </span>The set of messages to which an object responds to is known as its
<b>interface
</b>. A set of messages that
</p>
27 <p class=
"p3">implement a specific kind behaviour is known as a
<b>protocol
</b>. An object's interface may include several protocols which allow the object to interact in several different contexts. For example all objects implement the 'dependancy' protocol which allow the object to notify other dependant objects that the object has changed and that the dependant should do any necessary action to update itself.
</p>
28 <p class=
"p2"><br></p>
29 <p class=
"p3"><span class=
"Apple-tab-span"> </span>An object's internal state may only be changed by sending it messages. This allows the implementation of the object to be hidden from the client. The advantage to this is that the client does not depend on the object's implementation and that that implementation can be changed without having to change the client.
</p>
30 <p class=
"p2"><br></p>
31 <p class=
"p4"><b>Classes, Instance Variables, Methods
</b></p>
32 <p class=
"p2"><br></p>
33 <p class=
"p3"><span class=
"Apple-tab-span"> </span>An object's
<b>class
</b> contains the description of the object's data and operations. A class
<span class=
"Apple-converted-space"> </span>also describes
</p>
34 <p class=
"p3">how to create an object which is a instance of that class.
<span class=
"Apple-converted-space"> </span></p>
35 <p class=
"p2"><br></p>
36 <p class=
"p3"><span class=
"Apple-tab-span"> </span>An object's data is contained in its
<b>instance variables
</b>. These are named variables that describe
</p>
37 <p class=
"p3">the object's state. The values of the instance variables are themselves objects. For example, instances of class Point have instance variables named 'x' and 'y' which contain the coordinate values of the Point.
<span class=
"Apple-converted-space"> </span></p>
38 <p class=
"p2"><br></p>
39 <p class=
"p3"><span class=
"Apple-tab-span"> </span>An instance variable is only directly accessible from within the class itself. The author of a class may decide to expose instance variable access to clients by adding
<b>getter
</b> and/or
<b>setter
</b> messages to the class.
</p>
40 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
41 <p class=
"p3"><span class=
"Apple-tab-span"> </span>A
<b>method
</b> is a description of the operations necessary to implement a message for a particular class. The methods in a class tell how to implement messages sent to its instances. A class contains a method definition for each message to which its instances respond. Methods generally
<span class=
"Apple-converted-space"> </span>fall into several categories. Some methods inquire about some property of the receiver. Others ask the receiver to make some change to its internal state. Still others may ask the receiver to return some computed value.
</p>
42 <p class=
"p2"><br></p>
43 <p class=
"p4"><b>Summary of Terminology
</b></p>
44 <p class=
"p2"><br></p>
45 <p class=
"p3"><b>object
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>something that has data, representing the object's state, and a set of operations
</p>
46 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>that can be performed on the object.
</p>
47 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
48 <p class=
"p3"><b>message
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a request for an object to perform an operation.
</p>
49 <p class=
"p2"><br></p>
50 <p class=
"p3"><b>receiver
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>the object to which a message is sent.
</p>
51 <p class=
"p2"><br></p>
52 <p class=
"p3"><b>class
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a description of the state and behaviour of a set of objects.
</p>
53 <p class=
"p2"><br></p>
54 <p class=
"p3"><b>interface
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>the set of messages to which an object responds.
</p>
55 <p class=
"p2"><br></p>
56 <p class=
"p3"><b>protocol
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a set of messages that implement a specific kind of behaviour.
</p>
57 <p class=
"p2"><br></p>
58 <p class=
"p3"><b>polymorphism
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>the ability for different kinds of objects to respond differently to the same message.
</p>
59 <p class=
"p2"><br></p>
60 <p class=
"p3"><b>method
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a description of the operations necessary to implement a message for a particular class.
</p>
61 <p class=
"p2"><br></p>
62 <p class=
"p3"><b>instance
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>one of the objects described by a class.
</p>
63 <p class=
"p2"><br></p>
64 <p class=
"p3"><b>instance variable
</b><span class=
"Apple-tab-span"> </span>a part of an object's internal state
</p>
65 <p class=
"p2"><br></p>