Closed atticoos closed 4 years ago
I couldn't tell you how most syntactic language features like this work under the hood, so I can't argue for or against this other than "yea, it should, just like it would for other bracket-notation access a[(() => 1)()]
".
I imagine it's expected to support dynamic usage like this.
This is how it works in Python:
a = 1
b = lambda: 1
c = [1, 2, 3, 4]
c[1:3] # [2, 3]
c[a:3] # [2, 3]
c[b():3] # [2, 3]
Note: the last index is not included in the slice, it's from the first until the second.
Sounds good to me, my only suggestion here is to use AssignmentExpression instead of Expression.
The proposal and its examples show static usage
Eventually the question will be raised if access can be done dynamically by an expression:
Whether it's by variables
Or with operators
Or other expressions