- Installing
- Hello World
- Spaces
- Identation
- Basics
- Comments
- Output
- ++ method
- Assignments and types
- Operator Precedence
- String interpolation
- Input
- Simple arithmetic
- Multiline strings
- Assert
- Arrays and literal arrays
- Literal intervals
- If, for, while and repeat-until
- Message sends
- Conversion between basic type values
- Anonymous function
- Evaluating an anonymous function
- Functions with method foreach
- Prototypes
- Packages
- Gradual typing
- Generic prototypes
- Important metaobjects
- The CyanInterpreter prototype
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 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; ... }