aboutsummaryrefslogtreecommitdiff
path: root/notes/multiline_exprs.txt
blob: 34af72ad30588b2b3de5af07b3dde8d5153fff8a (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

Syntax 1: Parentheses
---------------------

    int func_ret = (do_stuff
            x
            y
            z)

    []int array = [
            1
            2
            3
        ]


Syntax 2: `with` for functions
------------------------------

    int func_ret = do_stuff with
            arg1 = x
            arg2 = y
            arg3 = z
    end

    []int array = [
            1
            2
            3
        ]

    # Or, using `with` for even for arrays:
    []int array = with
            1
            2
            3
    end


Syntax 3: With line continuations at end
----------------------------------------

Note that the last line shouldn't have any `\` (which is a bit unintuitive)

    int func_ret = do_stuff     \
            x                   \
            y                   \
            z

    # Should line continuations be required in this case?
    []int array = [     \
            1           \
            2           \
            3           \
        ]


Syntax 4: With line continuations at start
------------------------------------------

This would require look-ahead in the parser. Also, code editors won't be
able to auto-indent :(

    int func_ret = do_stuff
    |       x
    |       y
    |       z

    # Should line continuations be required in this case?
    []int array = [
    |       1
    |       2
    |       3
    |   ]

Syntax 5: Special long-line block
---------------------------------

    longline
        int func_ret = do_stuff
                x
                y
                z
    end

    # Should a lone-line block be required in this case?
    longline
        []int array = [
                1
                2
                3
            ]
    end

Syntax 6: Line-continuation-start and line-continuation-end
-----------------------------------------------------------

I find this quite intuitive. But I don't think it's used by any other
programming language:


    int func_ret = do_stuff ...
            x
            y
            z  ;

    []int array = [ ...
            1
            2
            3
        ] ;