HigherOrderCO/Bend

Ambiguous fork statement

Closed this issue · 1 comments

Reproducing the behavior

When writing a bend/fork like this, the code will run:

def example(i, value):
  bend n = 0:
    when n < i:
      result = (n, fork(n + 1, value))
    else:
      result = value
  return result

def main():
  return example(4, 22.2)

However, the result is non-intuitive, as it returns (0, 22.200), which implies that the condition on line 3 was never met.

Obviously the problem has something to do with the second parameter of the fork (value), which shouldn't be there.

It seems that forking with a different number of arguments than the bend statement declares, should throw an error or that the extra argument is simply ignored as it has no clear meaning. Now neither is the case.

System Settings

Bend 0.2.33

Additional context

No response

Yes, passing the wrong number of arguments will break your program.
Bend is untyped and fully curried, so we have no way of knowing if passing an extra argument is valid or not.

We could add a special check for fork to force you to pass exactly the expected number of arguments, but I'd rather wait for us to add a type checker instead of adding a lot of bandages to try to fix something that is fundamentally unfixable with our approach.

Closing as a duplicate of #282