aboutsummaryrefslogtreecommitdiff
path: root/notes/scoping.txt
blob: 990db94b3c509e271ee5f9736a2db3d28e364a6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Local variable scoping
======================

With type inferrence (including name-based type inferrence),
it is possible to end up with code like this:

    if is_red
        item <- red_item
    else
        item <- blue_item
    end
    add items item

Should it require a declaration before the `if`?

Loops DON'T have the same issue!

    for item in items
        process_item item
        last <- item
    end
    # Compilation error: `last` might not be set at this point
    set_active_item last