Be able to have a node (or subcomposition) execute another node (or subcomposition). Some examples where this would be useful...

Provide higher-level nodes that encapsulate bigger tasks, so that you can save time by using these nodes instead of having to build up the same composition structures over and over. For example, a "Slideshow" node could input a list of images and a list of nodes that transition between images.

Another higher-level node, suggested by @ajm, is a "Filter" node that could input a list of data and a node that outputs a boolean (yes/no) to decide if each data item should be passed through to the output list or filtered out.

Select between different nodes to execute, such as different image filters. You can do this currently with the Select nodes, but it can be clumsy to build a composition that does it optimally (only executing the currently selected node).

"For Each" node (or "Map" node, mentioned by @ajm) — Do something with each item in a list. A different way (perhaps more convenient in some cases) to accomplish the same thing as Iteration: Turn most nodes into iterators by allowing single-value ports to accept lists.

Implementation:

  • Add a special output port to some/all nodes — "function port".
  • Enable a node to have an input port that can be connected with a cable to another node's function port.
  • Enable a node or subcomposition to execute a node passed in through a function port.

To be determined:

  • Will all nodes have function ports, or only certain ones (such as stateless nodes)?
  • Many design and UI issues.

Component: 

Notes from Team Vuo

Vuo Pro: 

No — available with both Vuo and Vuo Pro licenses

Complexity: 

●●●○ — A few months of work

Comments

This sounds cool but I'm

ajm's picture
Submitted by

This sounds cool but I'm having trouble imagining how it would work.

Can all nodes be passed as values (I'm picturing an extra port on the bottom), or only subcompositions?

Passing functions makes me think of a couple things:

clojures / capturing binding / scope / partial application

It seems sort of central to Vuo that nodes don't have any scope/bidings that they aren't passed explicitly, so it's difficult to imagine what a closure would capture.

We can already do partial application explicitly by, for example:

  • Instantiating a Count Within Range
  • Set several (but not all) of the input ports
  • Publishing a couple input ports and the output port
  • Saving that single node as a submodule to the node library

classical higher order functions like map/filter/reduce

iteration seems pretty similar to map, in practice—apply a function to a collection of values and return a new collection of values.

Process List and map are isomorphic: they do the same thing. It gives us a model for how to implement other higher order functions.

I tried out implementing filter, both with and without function passing.

Assume the orange nodes are published ports. The top clump is the submodule definition, and the bottom clump uses the defined submodule in green.

Here it is as a regular submodule:

filter today

And here it is using function passing. Assume that Apply accepts a function in its event port, and applies it to the value coming in its value port:

filter with function passing

I think I like the first one more, it feels simpler and more explicit. A more complex example may shed more light.

Process List is essentially a higher order function already. We get to explicitly pass both the input and output ports, which I think is even more powerful than just passing a function because we can pass a more complex structure of nodes without composing it into a subcomposition, if we want to.

Since Vuo doesn't really have a notion of scope, I can't think of anything I could do with function passing that I couldn't do as easily with the existing subcomposition system. This is probably a lack of imagination on my part, but I think improving submodule support, (including local submodules) would achieve the same benefits as function passing, but with more generic and broadly applicable benefits.

@ajm, I just filled in the

jstrecker's picture
Submitted by

@ajm, I just filled in the description on this feature request. Does that answer all your questions?

Filtering a list actually can't be accomplished with Process List, or not easily. The reason your mockup with the Select Input inside of a Process List loop wouldn't work is that the events fired from Process Item need to match the events received by Processed Item one-to-one, or else Processed List won't fire.

Feature status

When we (Team Vuo) plan each release, we try to implement as many of the community's top-voted feature requests as we have time for. Vote your favorite features to the top! (How do Vuo feature requests work?)

  • Submitted to vuo.org
  • Reviewed by Team Vuo
  • Open for community voting
  • Chosen to be implemented
  • Released

Votes

11 votes so far!

Who voted?

ajm's picture
useful design's picture