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

Controlled expansion of recursive calls #68

Open
TomasMikula opened this issue Apr 23, 2022 · 0 comments
Open

Controlled expansion of recursive calls #68

TomasMikula opened this issue Apr 23, 2022 · 0 comments
Labels
enhancement New feature or improvement of programmer experience

Comments

@TomasMikula
Copy link
Owner

Problem

Expanding recursive calls eagerly will lead to OutOfMemoryError.

It is currently not common because

  1. recursive calls are usually in a conditional branch (|+| or |&|); and
  2. we expand only the branch that will be executed, and thus delay the expansion until the branch is known.

However, there are useful (infinite) programs that have an unconditional recursive call. Although the recursive instance of a function might stay inactive until input flows into it, expanding the function eagerly leads to OutOfMemoryError.

TODO: provide an example

Proposed solution

Introduce a recursion operator that keeps recursive calls unexpanded (and thus also inactive) until an activation signal is received.

def controlledRec[A, B](((Ping |*| A) -B) => (A -B)): A -B

Care needs to be taken around crash and cancellation of unexpanded functions:

  • The frontier is impermeable to a propagating crash (just like to any other in-flow).
  • However, cancellation should propagate, but expand only as much as necessary.
  • If the activation Ping signal crashes, the whole frontier crashes/cancels.
@TomasMikula TomasMikula added the enhancement New feature or improvement of programmer experience label Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement of programmer experience
Projects
None yet
Development

No branches or pull requests

1 participant