martmists
05/04/2022, 11:33 PMclass MonoNode : BaseNode() {
protected val input by input() // getValue should resolve here; it's a delegate to use the property name
protected val output by output() // getValue should not resolve as its value may change over time
override fun process() {
// We don't want to call getValue too often in real-time code that needs to be fast!
// output.getValue should only be called once per process() call
// input.getValue should only be called in constructor/init
// Is there a good way to do it without having to store to a variable?
val x = input[0] // calls input.getValue
val y = input[1] // calls input.getValue
output[0] = x + y // calls output.getValue
output[0] = x + y // calls output.getValue
}
}
Chris Lee
05/05/2022, 12:26 AMlazy
to memoize values, such that the ‘expensive’ portion only occurs on the first call.