aboutsummaryrefslogtreecommitdiff
path: root/notes/struct_init.txt
blob: 8a76a05d5d8547b2f0f25bfc3e02db77382124db (plain)
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

Struct initialization
=====================

How to initialize structs without `{` and `}` ?

Options for the enclosing syntax:

* Use [], like for arrays, but with designated initialization of fields.
* Use some keywords, for example `struct` and `end`

Options for initialization:

* Use <-
* Use =
* Use :

Syntax test:

    Point p1 = [
        x = 12
        y = 34
    ]

    Point p2 <- [
        x = 12
        y = 34
    ]

    Point p3 <- [
        x <- 12
        y <- 34
    ]

    Point p4 <- [
        x: 12
        y: 34
    ]

    Point p5 <- struct
        x <- 12
        y <- 34
    end


Best syntax?

    Point p4 <- [
        x: 12
        y: 34
    ]