For loop in APEX: what goes to __spare__?

   486   1   1
User Avatar
Member
213 posts
Joined: June 2023
Offline
For example, say I have this loop:



Since weightsdoesn't change during the loop, I thought I can directly connect it like this.

However, it seems to be causing a very obscure bug. Passing it to __spare__fixes them:



It's quite hard to explain what kind of bug I've run into, since it only happens in a rather complicated rig of mine. The only thing I know is that passing an array that doesn't change during the loop to __spare__fixed it.

Is there an official explanation of this __spare__thing and what should be connected to it?

Attachments:
Screenshot 2024-01-17 095921.png (84.3 KB)
Screenshot 2024-01-17 100157.png (86.6 KB)

User Avatar
Member
7743 posts
Joined: July 2005
Offline
In the next major release, we're going to be stricter with this. Passing anything you use inside a loop through the "spare" is the right thing to do as it allows better topological sorting of the graph for evaluation. This includes nodes inside If blocks as well.
Edited by edward - Jan. 19, 2024 15:44:04
  • Quick Links