Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove multi-level index operator #188

Open
jlapeyre opened this issue Mar 24, 2024 · 0 comments
Open

Remove multi-level index operator #188

jlapeyre opened this issue Mar 24, 2024 · 0 comments

Comments

@jlapeyre
Copy link
Collaborator

We copied the idea of treating [][] in a sense as a single operator. For example in the expression v[i][j]. This was copied from the reference parser. The reference parser in turn seems to be influenced by the way composition of indexing is presented in the spec.

However, I think this is a clumsy and complex approach. I am unaware of any language that treats v[i][j] differently than (v[i])[j]).

We should re-implement this in the standard way. I could list reasons, but I don't know who I'm trying to convince.

  • The complexity of [][] is currently handled everywhere by code to check how many indexing ops are present and to organize them in an array. Or organize them by marking a stream with tags as in the green tree, etc. If this is instead treated as two separate indexing operations, then all complexity is handled by the generic machinery for handling expression trees, with no special provisions.
  • The same argument above applies to all analysis, such as semantic analysis. There is generic machinery for analyzing nested expressions. As it is, we have to implement some parallel machinery just to handle repeated indexing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant