Skip to content

Add support for tailstrict#257

Merged
stephenamar-db merged 4 commits intomasterfrom
tailrec
Jan 18, 2025
Merged

Add support for tailstrict#257
stephenamar-db merged 4 commits intomasterfrom
tailrec

Conversation

@stephenamar-db
Copy link
Collaborator

@stephenamar-db stephenamar-db commented Jan 4, 2025

With this PR, I'm implementing tailstrict in sjsonnet.
I'm following the guidance from google/jsonnet#343 (comment):

Quote:

  1. If you call a function with tailstrict annotation on the apply AST, e.g. foo(42) tailstrict then the evaluation of the function body happens in "tail strict mode". The annotated AST need not actually be a tail call. Also, the arguments of this function are forced.
  2. When another function call (can be a completely different function to the one that was originally called) is made when we're evaluating in "tail strict mode" and it is a tail call, then the current stack frame is re-used for the next call, rather than being pushed on top of.
  3. Note that in order to preserve the tail strict mode into the new function, the new call AST has to be tailstrict as well.

Resolves #189.

@stephenamar-db stephenamar-db force-pushed the tailrec branch 2 times, most recently from 938d7e9 to 4eb8b30 Compare January 8, 2025 00:08
@stephenamar-db stephenamar-db changed the title tailstrict Add support for tailstrict Jan 8, 2025
@stephenamar-db stephenamar-db marked this pull request as ready for review January 8, 2025 00:19
@stephenamar-db stephenamar-db merged commit f41fd4b into master Jan 18, 2025
6 checks passed
@stephenamar-db stephenamar-db deleted the tailrec branch January 18, 2025 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sjsonnet does not support recursive functions/tailstrict

2 participants