So I know that the whole Grasshopper set-up doesn’t do recursion.
But what happens if you have a script that includes a Hops component that points to its own file? Could you open the pandora’s box of recursion?!
Sadly no. When I try to save the .gh file, Grasshopper hangs, presumably because it is trying to save itself, plus all the files it (recursively) depends on, which is itself, which depends upon itself, etc. Technically, this is a bug, because we don’t want the Grasshopper editor to freeze when saving.
Here’s a Grasshopper file with two Hops components. that was supposed to recurse upon itself (to draw a recursive binary tree). In theory you would take the two Hops components and Set Path them to the file itself. This is a Rhino8 Grasshopper file.
Recursion.gh (14.4 KB)
But in practice, I guess it’s a no go on recursion.
I understand why, but I do feel a little disappointed.
(Recursion can lead to insanely complicated scripts, not to mention unintentional infinite loops, stack-over-flows, memory overflows, etc.)
I suppose one might try to “trampoline” the recursion?
Grass1.gh has a Hops component that points at Grass2.gh.
Grass2.gh has a Hops component that points at Grass1.gh.
Probably run into the same problem… but might be worth checking for laughs and giggles.
P.S. If the dependency-graph of Hops components must be a DAG (directed acyclic graph), then probably worth pointing that out in the documentation. But if cycles are allowed, in some ways, then we get recursion! And that too is worth pointing out in documentation? Unless you want to keep that feature a secret… XD