What I understood from documentation is that main difference between Pure and Impure is that Pure promises not to modify ‘this’ object in any way. So it seemed to me to be like ‘const function’ in C++. But that’s not it as it also has no Exec input/output.
So let’s say I’d make a function that just prints values of class variables to log. Such function doesn’t modify the object in any way. So it kind of could be a Pure function. But if we do that there’s no way to call it. So in order to be able to call it, it has to be Impure.
So what is actually Pure/Impure about?
The logging function you mention, is really a procedure. That’s why it needs to exec lines.
My interpretation is that pure means function in the mathematical sense. y = f(x)
Pure functions are for such Things as Calculating mathematical Expressions without the Need of being Executed.
f.E.: Setting Variables need to be impure, cause the Set Nodes need to be Executed in the Node Line.
Getting Variable Stuff instead, can be pure, since the getting Nodes just take the values of a reference.
pure functions are working on select, get and operate.
As far as i know, you can´t take a result of an impure function after 1-X frames have passed, since the reference gets lost/overwritten. While pure functions can be used as returner multiple times, no matter how many time has passed since the first call.
Believe a pure functions will do everything again every time you request data from it.
I use impure function, if the later frames have no need for the return…
And pure ones for dealing with calculations and Clamp>Select stuff, that i need more often.
Here’s a good read with some examples
You are correct in that printing could technically be a pure function but they likely did not make it that way so that you can execute it wherever you might want to.
I’ve always used pure functions for slightly complicated getters. Think of get actor/component transform where you’re running some calculations before returning the value. As the link suggests, there are some considerations and pitfalls. Hope this helps.