-
Notifications
You must be signed in to change notification settings - Fork 308
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
keywords as selectors #301
Comments
Good catch @ozanh . I think it’s a good idea to fix this. |
Yes @geseq I think I should create a PR for this. But I will keep parsing map element literal as it is because |
Yes I think map element literals should be defined by whatever type they are (in your example a string so it should be within quotes) |
@d5 if you are OK with using keywords as selectors I will create a PR. Let me know please. |
When implementing the first version, I simply followed Go's struct syntax where a.for = 1 is invalid, but a["foo"] = 1 is valid in Tengo. So we have 3 options here:
My concern for option 1 is that we might introduce some edge cases in parser and compiler. Option 2 implementation can be really tricky and even have a performance overhead. Option 3 is not ideal I guess but maybe we can just clarify that in the documentation? |
Tengo consistently uses lower cases for keys, function names and underscores in the documentation and somehow it has bitten me while writing |
Yeah I'd prefer adding some documentation about this limitation (option 3) rather than adding more complexities/overhead in parser/compiler/runtime. |
@d5 Actually, using keywords as selectors ( |
I've realized that keywords cannot be used as selectors. Followings are not parsed;
https://tengolang.com/?s=2dbaf9a98cff105d9231209806f40f87ef51c105
Is it possible to use keywords as selectors by changing the parser? I can try to create a PR for this.
I want to do
console.log.error("this is an error)
or use other keywords as selectors. What do you think @d5 @geseq ?The text was updated successfully, but these errors were encountered: