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

Add possibility of forward declarations #3230

Open
lukaszcz opened this issue Dec 5, 2024 · 1 comment
Open

Add possibility of forward declarations #3230

lukaszcz opened this issue Dec 5, 2024 · 1 comment

Comments

@lukaszcz
Copy link
Collaborator

lukaszcz commented Dec 5, 2024

This has come up during Advent of Code.

Example:

  • you have a large constant data which you use in the file,
  • you want to put it at the end because it's too big, but it's not currently possible - variables need to be defined before being referenced,
  • a workaround is to define data in a separate module and import the module.

One could want to have it in the same module, but at the end, with a forward declaration at the beginning.

@janmasrovira
Copy link
Collaborator

janmasrovira commented Dec 5, 2024

I believe we explicitly decided to have variables (or definitions that are not function-like) to not be recursive, and hence, not 'forward-referencable'. If having data at the end of the file is the only use case we have for this, I don't think it justifies any change in the language.
Moreover, even if it was possible, I think it'd be better style to have data-like definitions in a separate file.

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