FLoWS vs WarpScript
This tutorial is for you if you already know WarpScript. It will help you to spot differences, and to make a smooth transition to FLoWS if you wish to.
Using FLoWS inside WarpScript
FLoWS has no dedicated endpoint in Warp 10 yet. It is packaged as an extension that provides the
FLOWS function. The
FLOWS function takes a STRING containing the FLoWS code to execute as input.
Wrap your FLoWS code into a WarpScript multiline string, then call
FLOWS. All the tooling (WarpStudio, VSCode extension) do this wrapping for you.
FLOWS function executes the FLoWS code in an execution environment identical to that of WarpScript, there is no prior conversion to WarpScript code though. Your FLoWS code can nevertheless be transpiled into WarpScript code via the use of the
Using the same execution environment means your FLoWS scripts share all the already defined variables, WarpScript macros, bootstrap scripts, redefined functions.
Running FLoWS inside WarpScript is safe, but FLOWS does not perform a context backup/restore: FLoWS can alter WarpScript variables.
Using WarpScript inside FLoWS
In WarpScript, you can run WarpScript from WarpScript with the EVAL function. EVAL is also available in FLoWS, so you can run WarpScript within FLoWS.
Running WarpScript inside FLoWS can be risky: Be careful with stack manipulation and what you leave on the stack.
What you cannot do in FLoWS
- You should not use stack manipulation functions (
ROT...). It is not forbidden, but it can lead to unexpected errors. As FLoWS always leaves the stack empty after statements, you do not need these functions.
- The only collection type you cannot write explicitly in FLoWS is WarpScript SET. A set is a collection of unique objects. SET objects can only be created from a list with the help of the ->SET function. See example below.
FLoWS is simpler to learn, read and maintain. It comes with a small performance hit: FLoWS takes extra precautions to ensure the execution environment (the infamous stack) is kept clean and enforces strict checks on parameter and return value count. So... They are some extra functions called behind the scene. You can roughly check what is done by looking at the WarpScript equivalent of your FLoWS code via the
These extra functions are fast to execute, but it still is a small CPU overhead.