“Control flow”指程序(或算法)中语句执行的先后顺序与路径,通常由顺序执行、分支(如 if/else)、循环(如 for/while)、函数调用、异常处理等结构共同决定。(在更广义的语境中也可指流程/工作流中的控制路径。)
/kənˈtroʊl floʊ/
The control flow is simple: it checks the input and then prints a result.
控制流程很简单:它先检查输入,然后输出结果。
To improve readability, she refactored the function so the control flow handles errors early and keeps the main logic clear.
为了提高可读性,她重构了这个函数,让控制流程先处理错误,并保持主逻辑清晰。
“Control”源自法语 contreroller(核对、检验账目,后来引申为“控制、支配”),而“flow”来自古英语 flōwan(流动)。组合成“control flow”后,在计算机科学中用来比喻执行会“流向”哪条路径由结构来“控制”。