Closure (computer programming): Difference between revisions

Content deleted Content added
Tweak cites | Alter: url, pages. URLs might have been anonymized. Add: archive-date, archive-url, s2cid. | Use this tool. Report bugs. | #UCB_Gadget
m Nested function and function pointer (C): "provided" is the more typical grammatical use in writing per m-w.com and https://dictionary.cambridge.org/grammar/british-grammar/conditionals-other-expressions-unless-should-as-long-as
Line 357:
With a [[GNU Compiler Collection]] (GCC) extension, a nested function<ref>{{cite web
|url = https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html
|title = Nested functions}}</ref> can be used and a function pointer can emulate closures, providingprovided the function does not exit the containing scope. The next example is invalid because <code>adder</code> is a top-level definition (depending on compiler version, it could produce a correct result if compiled with no optimizing, i.e., at <code>-O0</code>):
 
<syntaxhighlight lang="c">