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

Allow mutual recursion without forward declaration #976

Closed
WardBrian opened this issue Sep 28, 2021 · 0 comments · Fixed by #1277
Closed

Allow mutual recursion without forward declaration #976

WardBrian opened this issue Sep 28, 2021 · 0 comments · Fixed by #1277
Assignees
Labels
feature New feature or request typechecker

Comments

@WardBrian
Copy link
Member

Relevant to @bob-carpenter 's comment here: stan-dev/docs#408 (comment).

We currently allow functions to call themselves without a forward declaration, but mutual recursion would still require at least some subset of the required functions to be declared. We can instead do a first pass through the function block which only adds each function's signature to the symbol table, and then our second pass as normal which checks the bodies etc. This would mean all functions are available to all other functions in an order-independent way.

After this change, function declarations are only really useful for defining functions in other (stan|c++) files. In the long term we may want to move toward this being the only valid use of them for simplicity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request typechecker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant