aboutsummaryrefslogtreecommitdiff
path: root/notes/func_ident_lookup.txt
blob: 351b84fb082b546bdf977ead08c48a276e0a288f (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

Function identifier lookup
==========================

Types of functions:

* constructors / typeident-based functions
* object functions / methods
* bare functions

Syntax decisions:

* whether to have an explicit or implicit this parameter?
* typed function definitions
* simplified / variant-typed function definitions
* function calls

Syntax with implicit `this` parameter
-------------------------------------

Possible function definition syntax for typed definitions:

    constructor new
        bool shiny
    ...

    func get_item
    returns
        Item
    ...

    static compare_items
        Item a
        Item b
    returns
        bool equal
    ...

Possible function definition syntax for simplified / variant-typed defs:

    constructor new shiny
    ...

    func get_item -> item
    ...

    static compare_items a b -> equal
    ...

Possible function call syntax:

    func item_exists
    func get_item -> item
        # Implicit `this`-parameter
        # See call_vs_field_syntax.txt
        # (but maybe fields can be accessed by first "importing" them
        #  via `modifies`/`accesses` block in the function decl)
        if item_exists
            return retrieve_item
        end
    end

This syntax probably prevents usage of `f obj p1 p2 `... syntax for calls
on other objects due to ambiguities. It probably has to to `obj.f p1 p2`...
instead.