neva
neva copied to clipboard
Closure (Implement "visibility scope" via hierarchy of deferred connections)
In control flow languages we have concept of scope
a = foo()
b = bar()
baz(a)
The reason for that is that in a control-flow language you describe program as a sequence of things that happens one after another in a single thread. So when we print(a,b)
we sure both a and b exist and foo
and bar(a)
were computed. However, that's not the case for dataflow language
foo -> print
bar -> del
We send message from foo
to println
while knowing nothing about whether bar
already sent or not. There is a solution for that problem - locks.
foo -> lock:data
bar -> lock:sig
lock:data -> println
However, our program just got harder to understand. And the more complex control-flow we need, the more locks and related connections we gonna have.
Scope Proposal
foo -> (
bar -> (foo -> baz)
)
Right now this program considered invalid (see #501 for more). The idea is to change that by making compiler handle this in a specific way
bar -> lock1:data
foo -> [lock1:sig, lock2:data]
bar -> lock2:sig
lock2:data -> baz