-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.ms
53 lines (40 loc) · 973 Bytes
/
example.ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module acme.main;
import ltd.fmt;
/**
* Point represents a point in the 3D space
*/
type Point : class {
var x : int;
var y : int;
var name : String;
pub func getCoordinate : () -> (int, int | Status) const
{
return x, y, Status.Ok;
}
pub func setCoordinate : (x : int, y : int) -> Status
{
self.x = x;
self.y = y;
return Status.Ok;
}
pub func setName : (in name : String) -> Status
{
self.name = name;
return Status.Ok;
}
};
// Get the origin of a point;
func origin : (out ori : Point) -> Status
{
ori.setCoordinate(0, 0);
ori.setName("Point of origin");
return Status.Ok;
}
func main : () -> int
{
var p = new Point(10, 10);
fmt.println("%d, %d", p.getCoordinate())
| Status.ErrEmptyCoordinate => fmt.println("Coordinate is empty")
| Status.NullException => fmt.println("Cannot process null coordinate");
return 0;
}