-
Notifications
You must be signed in to change notification settings - Fork 0
/
NOTE
42 lines (30 loc) · 1.47 KB
/
NOTE
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
## Vars, fields and scopes
Toplevel:
- vars are defined with `var`
- vars are local, it is simply the toplevel scope, accessible from everywhere
- no forward declarations
Block:
- vars are defined with `var`
- vars are local
- vars referenced are searched in the current scope, then in the outer scopes
up to the toplevel
- no forward declarations
- assignments to non-var identifiers are updates of block fields
Last point requires some deeper digging. It might be that what looks like
block field update will be actually an inner var update. It will be better
to provide some syntax to make it clear.
Similar with print vs eval: now the var update can happen inside print, not only
eval; it can actually happen anywhere expr is expected, because assignments are
also expressions. This might be surprising for some users, while others can
possibly embrace it. So, restricting when assignment can happen is to be thought
about carefully.
Note the differences from yacc-based bcl, where vars were global and it was
possible to have forward declarations, with some special detection of cycles.
## Reading multiple files
To be decided: many progs, or one concatenated prog?
Many progs: what about visibility of the vars and blocks?
Concatenated prog:
- needs adapting lexer to process multiple inputs, then the token needs
input file ref together with pos, same for prog positions and linePos
In general, it's about handling many files as separate compilation units,
or preprocessing them.