Message sends

Message sends

In the following statement

var p = Person clone;

Person clone is sending the message clone to prototype Person and “clone” is called the “selector”of the message

p setName: name;

is the sending of message “setName: name” to the object referenced to byp. The message selector is“setName:” and “name” is the argument.

Out println: (p getName);

is the sending of message “println: (p getName)” to prototype Out. The message selector is “println:”and the argument is the object returned by “p getName”.

Cyan also supports keyword messages, a message with multiple keywords as in

var p = Point dist: 100.0 angle: 20.0;

Cyan calls dist: and angle: keywords. Following Smalltalk terminology, dist:angle: is called a “selector”

object Point
func dist: (Float newDist) angle: (Float newAngle) -> Point {
var p = self clone;
p dist: newDist;
p angle: newAngle;
return p
}
public Float dist
public Float angle
end

After a single keyword there may be multiple parameters:

func p1: (Int x1, Int y1)
p2: (Int x2, Int y2)
p3: Int x3, Int y3
p4: Int x4, Int y4 {
self.x = x1;
.
.
}