vvvv / VL-Language

The official repo for the design of the VL programming language
31 stars 0 forks source link

[CoreLib Proposal] ForEach State Management Refinements #65

Open gregsn opened 1 year ago

gregsn commented 1 year ago

Introduction

Some of our core regions manage state, even if they don't have "Manage", "State" or "Lifetime" in their names.

For E.g. a ForEach loop allows to use process nodes and will instantiate the patch inside the region once per index -> All process nodes in a ForEach exist several times.

Behavior over time:

Only when the count goes up from frame to frame new states will get created. The other ones get reused. And when the count goes down Patch-States / "Slices of the ForEach" will get disposed of.

So a ForEach region is as much a lifetime manager as ManageProcess, just for many instances of the patch (one per index).

However, currently, the patch instance gets also disposed of when the user feeds False into the Keep pin.

Proposed Refinements

Variations for determining the key:

We could throw away the complicated synchronizer regions and when a user creates a new ForEach enable this new behavior as the default.

Model-Runtime & Model-View synchronization, which is getting more and more common would get a lot simpler than current approaches.

gregsn commented 1 year ago

related: https://github.com/vvvv/VL-Language/issues/47

bj-rn commented 1 year ago

Seems related: https://discourse.vvvv.org/t/strange-behaviour-of-keep-in-foreach/21121

azeno commented 1 year ago

I have some recollection that I did a branch once where the loop behaved like described but it was disregarded as no use there are sync regions doing that ;)

will need to dig in our history how it was called..

azeno commented 1 year ago

Here it is (only visible in internal repo): https://github.com/devvvvs/vvvv/compare/dev/azeno/keyed-loop