Skip to content

Hoisting local variables or not #297

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

Closed
mihnita opened this issue Sep 15, 2022 · 6 comments · Fixed by #305
Closed

Hoisting local variables or not #297

mihnita opened this issue Sep 15, 2022 · 6 comments · Fixed by #305
Labels
resolve-candidate This issue appears to have been answered or resolved, and may be closed soon.

Comments

@mihnita
Copy link
Collaborator

mihnita commented Sep 15, 2022

Example:

let $foo = {$bar :number ...}
let $bar = {$count :number ...}

Is there a good use case for $foo to be able to refer to $bar?
I can't think of one.
Some programming languages do this, some don't, and I don't think those that don't have major problems.

Not allowing it would make things simpler:

  • you don't have to wait until everything is defined to validate and report errors
  • prevents circular references

Forked as a sub-issue from #292

@zbraniecki
Copy link
Member

I'd prefer to not allow for that.

@macchiati
Copy link
Member

macchiati commented Sep 16, 2022 via email

@eemeli
Copy link
Collaborator

eemeli commented Sep 17, 2022

I'm okay with not hoisting, as long as referring to variables defined earlier is considered valid:

let $bar = {$count :number ...}
let $foo = {$bar :number ...}

@stasm
Copy link
Collaborator

stasm commented Sep 23, 2022

+1 to not hoisting as well.

Also, I note that this is a revisitable decision, just in case we learn about use-cases for hoisting in the future. Not hoisting today is forward-compatible with hoisting in the future.

@stasm stasm added the resolve-candidate This issue appears to have been answered or resolved, and may be closed soon. label Sep 23, 2022
@mihnita
Copy link
Collaborator Author

mihnita commented Oct 16, 2022

In case if was not clear already :-)
+1 for not hoisting.

@mihnita
Copy link
Collaborator Author

mihnita commented Oct 16, 2022

as long as referring to variables defined earlier is considered valid:

I think that is still open to discuss (#292)
And not so much about if we should allow it (I think we should), but HOW we do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolve-candidate This issue appears to have been answered or resolved, and may be closed soon.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants