I would be nice to not rely on Global variables to hold a result that isn’t valid until the piston finished executing.
Calling a a piston with an opt var and having a result returned as a value would be great.
Sub/Function If execute piston(var) = “123” then …
Boolean - If execute piston(var) then …
Subroutine and Function call with results
I’m not sure I understand what you’re saying?
You are aware you can define local variables (piston specific) as well as global ones?
Functions are already built in by design but users can’t create them on the fly like VB or C++
In other languages you can call a subroutine or function with optional args. You can also define the piston as a data type, say Boolean. When you do the call the piston it becomes a Boolean variable.
That way you can use the call as part of a conditional without setting global variables and testing them after the fact. You also don’t need to wait for the piston to execute as the control of the program passes to the routine (synchronous) and resumes when the result is passed back.
In the example above the “execute piston(var)” would actually become a testable value when the piston was finished so you can use it in a conditional. Same with Boolean example but with no comparative, “execute piston(var)” becomes true or false depending on the outcome of the called piston as the called piston would be defined to return a Boolean value.
I just want to call a piston(args) and have it return a result in real time.
I know, clear as mud.
@daven, I posted a proof of concept for how pistons-as-reusable-functions could be approached with the capabilities available today. It’s not nearly as convenient as what you are suggesting but may be reasonable in scenarios where asynchronous processing is acceptable and the benefit of extracting logic out into pistons is great enough to justify a bit of overhead and boilerplate code.