Nu am putut găsi această intrare. Se afișează rezultate aproximative. Verificați ortografia sau propuneți adăugarea acestui termen în dicționar.
嵌套函数
Here is an example of a nested function from some real code
下面是真实代码中的嵌套函数的例子:
A "nested function" is a function defined inside another function.
"嵌套函数"是在另一个函数内部定义的函数。
In other words, var variables are defined from the beginning of the function, no matter where the definition is (assuming that the definition is not in the nested function).
Technically, the loop is more effective. These two variants do the same, but the loop does not spend resources for nested function calls.
从技术上讲,循环更有效。这两种解法的做了同样的事儿,但循环不会为嵌套函数调用消耗资源。
If f would have been a nested function we would still have run into the same problem and this is the reason they are not supported in C.
即使f 是个嵌套函数,仍然要面对同样问题,这也是C语言不支持嵌套函数的理由。 [6]
Sometimes it's ok to write.then directly, because the nested function has access to the outer scope (here the most nested callback has access to all variables scriptX), but that's an exception rather than a rule.
(Nested functions are not supported for GNU C++.) The nested function's name is local to the block where it is defined.
(GNU C++ 不支持嵌套函数)嵌套函数的名字域是它被定义的那个程序块。
But if there's a nested function that is still reachable after the end of f, then it has [[Environment]] property that references the outer lexical environment, so it's also reachable and alive
…但是如果有一个嵌套函数在 f 结束后仍可达,那么它的 [[Environment]] 引用会继续保持着外部词法环境存在:
It doesn't matter whether the function is created using Function Declaration or Function Expression. All functions get the [[Environment]] property that references the Lexical Environment in which they were made. So our new tiny nested function gets it as well.
Please note how memory management works here. Although makeCounter() call finished some time ago, its Lexical Environment was retained in memory, because there's a nested function with [[Environment]] referencing it.
There are three Algol features used in this program that can be difficult to implement properly in a compiler: Nested function definitions: Since B is being defined in the local context of A, the body of B has access to symbols that are local to A - most notably k which it modifies, but also x1, x2, x3, x4, and x5.
There is a limitation when passing parameters with modifier. All parameters in different level of methods should keep the same. For example, if we want to expand the code above to a general"+N" adder, one way is by nested function like this
The "Step" command goes into it and pauses the execution at its first line, while "Step over" executes the nested function call invisibly, skipping the function internals.
Exemplele au rolul de a te ajuta să traduci cuvinte sau expresii corect si adaptat la context. Nu sunt selectate sau validate manual, așadar pot conține termeni inadecvați. Te rugăm să raportezi exemplele pe care le consideri inadecvate. Traducerile vulgare sau colocviale sunt în general marcate cu roșu sau cu portocaliu.