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

Make view a soft keyword #2120

Closed
2 tasks done
dreamsmasher opened this issue Nov 3, 2022 · 0 comments
Closed
2 tasks done

Make view a soft keyword #2120

dreamsmasher opened this issue Nov 3, 2022 · 0 comments
Assignees

Comments

@dreamsmasher
Copy link
Contributor

dreamsmasher commented Nov 3, 2022

Issue To Be Solved

Function purity annotations were added in #1870 for Stable Cadence, allowing referentially-transparent functions to be annotated as such with the new view keyword.

We currently treat view as a hard keyword, which prevents it from being used as an identifier in any context. This is a problem, as the NFT contracts and many other on-chain contracts use it for arguments and variables, which breaks their code.

Suggested Solution

Make view a soft keyword in identifier position. This will require 1 token of lookahead in the parser when a view token is encountered - if it's followed by fun, then we know we're encountering a view function declaration or expression. Otherwise, it can be treated as an identifier. The list of soft keywords in the Stable Cadence changelog will also need to be updated.

Tasks:

  • Extend the parser
  • Update documentation and changelogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants