Open
Description
The problem
In code like the following:
const aaa = 0, bbb = 1;
we could improve our support for the name
scope.
The solution
We should probably handle the case of a simple initializer with only one variable separately from a multi-child one
Single-variable initializer
For example:
const aaa = 0;
In this case, we want the following:
- A single scope whose domain is the entire statement
This way you could say:
"name"
from within the statement to get the name"every name"
from anywhere in the block containing the statement (including within statement itself) to get all the names in that block
Multi-variable initializer
For example:
const aaa = 0, bbb = 1;
In this case, we want the following:
- one scope per nested assignment (
aaa = 0
andbbb = 1
) - a parent scope whose domain is the entire statement, and has multiple content ranges, one per sub-assignment name
- an iteration scope that is the entire statement
This way you could say:
"name"
from within a sub-assignment to get the name of that sub-assignment"name"
from the start / end of the statement to get all the names in that statement"every name"
from anywhere in the statement to get all the names in that statement"first name"
from anywhere in the statement to get the first name in that statement"every name"
from anywhere in the block containing the statement, except within statement itself, to get all the names in that block
Discussion
Note that we may want to use this pattern in other places
- Talon condition blocks
- Go return values
- Tags in
.scm
files