aboutsummaryrefslogtreecommitdiff
path: root/notes/declaration_syntax.txt
blob: 0546aa7f9cf6e57629b5ea7353293a18e5d0639a (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

Different declaration syntaxes
==============================

Current
-------

    func do_stuff
        Int x
        Int y
    returns
        Bool result
    code
        Int r = x + y
    end

- Becomes hard to read with long types.

C-like
------

    func Bool do_stuff
        Int x
        Int y
    code
        Int r = x + y
    end

Pascal-like
-----------

    func do_stuff: Bool
        x: Int
        y: Int
    code
        r: Int = x + y
    end

+ Handles long types nicely:

    l: List n Numeric String = new

- Type goes in the middle of declarations,
  which IMO makes them harder to read.

Really Pascal-like
------------------

    func do_stuff: Bool
        x: Int
        y: Int
    local
        r: Int
    code
        r = x + y
    end

+ Handles long types nicely
+ Easy to read declarations
- Extra lines to read for the developer