企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
一个return表达式可以返回也可以不返回一个值表达式: > A return expression can come with or without an value expression: ~~~ return; return expression; ~~~ 它会离开它被声明所在的控制流最深的函数,当局部函数(第5.11节)被调用时需要被区别: > It leaves the control-flow of the innermost function it is declared in, which has to be distinguished when local functions (5.11) are involved: ~~~ function f1() { function f2() { return; } f2(); expression; } ~~~ return会离开局部函数 f2,但不会离开 f 1,意味着 expression仍然会被执行。 > The return leaves local function f2, but not f1, meaning expression is still evaluated. 如果 return 不带值表达式使用,类型工具确保函数返回类型会返回Void 。如果它有一个值表达式,类型工具 统一(第3.5节)它的类型为它所返回的函数的返回类型(显式指定或者通过前面的return表达式推断)。 > If return is used without a value expression, the typer ensures that the return type of the function it returns from is of Void. If it has a value expression,the typer unifies(3.5) its type with the return type (explicitly given or inferred by previous return expressions) of the function it returns from.