Message sends

Message sends

Cyan was initially based on Smalltalk. As a result, it supports keyword messages, a message with multiple keywords as in

var p = Point dist: 100.0 angle: 20.0;

Both dist: and angle: are called keywords or message keywords. Following Smalltalk terminology, dist:angle: is called a “selector”.

object Point
func dist: (Double newDist) angle: (Double newAngle) -> Point {
var p = self clone;
p dist: newDist;
p angle: newAngle;
return p
func dist: Double dist { self.dist = dist } func angle: Double angle { self.angle = angle } func getDist -> Double = dist; func getAngle -> Double = angle; var Double dist
var Double angle

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;