Yeah, that’s what I figured, that it’s for tracking the side effects.
But I don’t get why we need closures for that yet. In other words, I imagine an alternative graph where if something is connected to the graph, then it gets included (doesn’t need a function invocation to track it).
So, imagining that possibility, I would guess that maybe the reason is that traversing the whole graph to find all those dangling side effects would be too complex? And having the context with function invocation is some way to simplify that to make it explicit?
Basically I’m just imagining a pure node graph, for example:
SomeValue
|
Boolean // SomeValue connected to Boolean would coerce it to true/false or 1/0
/\
/ \
/ \
IfTrue IfFalse
| |
Discard SomethingElse
|
Output // the Output is still the final result, regardless if Discard was a side effect i.e. a dangling branch
In this paradigm I’m describing, there’s no need to know about a concept of a “context” and requiring special function closure invocations to achieve results, the only thing required is to simply connect nodes together.
After all TSL is “nodes” right? But I think that TSL has gone beyond the scope of nodes (and it’s perhaps a good thing when it comes to shader-like code in JS).
Part of why I’m wondering about this is, because I’m trying to use the Node classes directly in that manner (in theory by simply connecting all needed nodes together, without any need for special function invocations),
but I’m not having luck reproducing that simple example in that format yet.
(If anyone knows how to complete the attempted example there, I’d be curious to see).
The reason to want to do that is simply: if we have an outcome simply representable with a node graph (just a web of connected nodes, no other constructs), then we can easily represent it with a visual GUI in a one-to-one mapping (all node map directly to GUI boxes, all node connections map directly to GUI lines). The logic node graph could very well be the main data structure for the UI.
And that makes me wonder if some TSL features are too abstract for (transcended beyond) a node graph concept to easily model with a graph UI (for example, I do not see If or Fn nodes in the nodes Playground, and my guess is that’s because If, Fn, and similar TSL constructs have transcended beyond the node paradigm into something of their own that isn’t immediately simple map to node representation (even if those things technically do extend from Node)).