Tagged articles
closures
55 articles · Page 1 of 1
This article explains Go's function syntax, closures, method definitions on structs, interface mechanics, and provides a concise overview of essential Go commands such as build, install, get, doc, test, list, and fix, illustrated with code examples and output results.
GoGo commandsclosures
0 likes · 11 min read

The article explains Go's core language constructs—functions (including parameter rules, multiple return values, named returns, and closures), methods on structs, and interfaces—illustrated with code examples, and then introduces common Go command‑line tools such as go build, install, get, doc, test, list and fix.
Goclosurescommand-line-tools
0 likes · 11 min read

This article explains PHP closures—anonymous functions that enable dynamic, reusable code—by covering their basic syntax, how to pass them as parameters, and how to generate variable functions at runtime, complete with clear code examples and practical explanations.
Anonymous FunctionsBackendclosures
0 likes · 4 min read

PHP 8.5 introduces support for closures inside constant expressions, allowing developers to define default parameter and property values directly with anonymous functions, and the article illustrates this new capability with clear code examples and explanations of its underlying rationale.
Default Parametersclosuresconstant-expressions
0 likes · 4 min read

This article walks you through Python closures step by step, starting with nested functions, explaining how closures capture outer variables, providing clear code examples, and highlighting practical use cases such as data hiding, factory functions, and decorators to make your code more modular and reusable.
Nested Functionsclosurescode reuse
0 likes · 5 min read

This article provides a comprehensive, step‑by‑step exploration of Swift closures on iOS, covering their definition, different forms, practical usage scenarios, the compiler’s SIL generation process, capture list behavior, memory storage details, and best practices for avoiding reference cycles.
Capture ListSILSWIFT
0 likes · 17 min read

This article uncovers five subtle JavaScript pitfalls—including async/await errors, Promise.all fail‑fast behavior, array mutation during iteration, closure‑induced memory leaks, and shallow versus deep copying—providing clear examples and best‑practice solutions to write more robust, predictable code.
Async/AwaitDeep CopyJavaScript
0 likes · 10 min read

This article explains Python's higher-order functions, covering their definition, how they can accept or return other functions, built-in examples like map, filter, reduce, and demonstrates custom higher-order functions, closures, and decorators with practical code snippets.
Pythonclosuresdecorators
0 likes · 6 min read

This article thoroughly compares Rust functions and closures, examining their static versus dynamic characteristics, ownership rules, type system implications, performance optimizations, and practical use‑cases, helping developers choose the right abstraction for safety, speed, and flexibility.
RustType Systemclosures
0 likes · 10 min read

This article explains Rust's closure system, detailing how the three traits Fn, FnMut, and FnOnce map to different capture modes and ownership semantics, and provides practical examples, common pitfalls, and performance tips for writing safe and efficient Rust code.
ConcurrencyFnFnMut
0 likes · 8 min read

This article explains Go closures—what they are, how they capture surrounding variables, key characteristics, practical code examples, common pitfalls like memory leaks and concurrency issues, and typical use‑cases such as function factories, state management, callbacks, and interface implementation.
ConcurrencyGobackend development
0 likes · 7 min read

This article explains the core concepts of function calls and references in Python, covering basic definitions, common calling methods, advanced applications such as passing functions as arguments, returning functions, using functions as objects, and includes numerous code examples illustrating direct calls, indirect calls, decorators, closures, and callbacks.
Function CallsFunction ReferencesPython
0 likes · 9 min read

This article explains how JavaScript closures, while powerful for encapsulation and modularity, can cause memory leaks, unexpected variable sharing in loops, and side‑effects when external variables are modified, and provides practical solutions such as releasing references, using let, IIFEs, bind, and immutable patterns.
JavaScriptLoopMemory Leak
0 likes · 6 min read

This article outlines eight frequent JavaScript traps—from type coercion and variable hoisting to this binding, closures, numeric precision, array method quirks, Promise misuse, and event‑listener memory leaks—explaining why they occur and how to resolve them.
JavaScriptPromisesbugs
0 likes · 5 min read

This article explains how PHP closures—anonymous functions that capture external variables—can be used to encapsulate reusable code blocks, demonstrates practical examples including data processing callbacks and integration with object‑oriented classes, and shows how this approach enhances code reuse, maintainability, and flexibility.
Anonymous FunctionsBackendclosures
0 likes · 4 min read

The article explains Function Object Programming (FOP) in PHP, outlines its drawbacks, and presents alternative approaches such as anonymous functions, class methods, and closures with code examples, concluding with practical usage scenarios and guidance on choosing the most suitable method.
Anonymous FunctionsFunction ObjectsPHP
0 likes · 4 min read

This article explains functional programming in PHP, highlights five typical closure mistakes such as incorrect declaration, reliance on globals, mutable variable modification, unpredictable side effects, and recursion misuse, and provides corrected code examples and best‑practice guidelines.
Best PracticesPHPbackend development
0 likes · 5 min read

This article explains how PHP's Closure class enables function object programming, detailing creation, invocation, advantages such as code reuse and modularity, and practical examples like higher‑order functions and callbacks, all illustrated with clear code snippets.
Code ReusabilityFunction ObjectsPHP
0 likes · 3 min read

This article explains how Python functions can be returned as values, covering simple functions, stateful closures, multiple returns, closures, decorators, function factories, anonymous lambda functions, and class methods, each illustrated with clear code examples and explanations.
closureshigher-order functions
0 likes · 6 min read

This article explains Go's function syntax, parameter rules, multiple return values, closures, method definitions with value and pointer receivers, and interface implementation, providing clear code examples and output illustrations to help developers deepen their backend programming skills.
Backendclosuresfunctions
0 likes · 10 min read

This article explains closures, anonymous functions, and higher‑order functions in Go, showing how to use closures, pass functions as arguments, and return functions from other functions with clear code examples and practical insights.
Anonymous FunctionsGobackend development
0 likes · 7 min read

V8 creates JavaScript closures by lazily parsing functions, using a pre‑parser to detect and record outer‑variable references, copying captured values to the heap, then generating bytecode that builds a function context and closure, ensuring efficient execution while avoiding memory‑leak pitfalls.
JavaScriptLazy ParsingV8
0 likes · 16 min read

This article explains PHP 7's enhanced anonymous functions and closures, demonstrating their syntax, usage as callbacks, and how they can simplify array processing through functions like array_map and array_reduce, ultimately improving code readability, maintainability, and flexibility.
Anonymous FunctionsPHPbackend development
0 likes · 5 min read

This article provides a comprehensive guide to advanced PHP features, covering magic methods, type hints, closures, namespaces, generators, iterators, date/time handling, regular expressions, and variable scope, each explained with clear descriptions and practical code examples for backend developers.
PHPbackend developmentclosures
0 likes · 18 min read

This article introduces three advanced PHP features—Closures, Generators, and Reflection—explaining their concepts, advantages, and providing detailed code examples that demonstrate how closures enable access to outer scope variables, generators reduce memory usage by yielding data lazily, and reflection allows runtime inspection and modification of classes and methods.
Advanced TechniquesBackendPHP
0 likes · 5 min read

This article explores how closures, currying, pure functions, thunks, and ES6 generators enable lazy evaluation in JavaScript, illustrating the concepts with code examples and showing how they can reduce unnecessary computation, control execution order, and even create infinite sequences.
CurryingJavaScriptThunks
0 likes · 11 min read

This article explains how closures and currying form the core of JavaScript functional programming, demonstrates multiple curry implementations, shows practical uses such as argument caching, debounce/throttle, and lodash utilities, and highlights their relevance for front‑end developer interviews.
CurryingJavaScriptclosures
0 likes · 14 min read

This article explores Go language closures and their delayed binding behavior through seven illustrative cases, detailed experiments, and code examples, clarifying value vs reference passing, goroutine timing effects, and practical pitfalls for developers.
ConcurrencyGoclosures
0 likes · 18 min read

This article explains how Go pointers work, why they differ from C pointers, and highlights frequent mistakes such as struct pointer assignments, for‑range loop quirks, closure captures, and memory‑escape scenarios, providing clear code examples and runtime insights.
Runtimeclosuresfor-range
0 likes · 13 min read

This article explains Python return functions and anonymous (lambda) functions, demonstrating how to create higher‑order functions, use closures to defer execution, and simplify code with lambda expressions, complete with practical code examples and detailed explanations.
Pythonclosureshigher-order functions
0 likes · 5 min read

This article explains Go's closure mechanism, showing how functions capture surrounding variables, how the compiler's escape analysis moves those variables to the heap, and how closures are internally represented as structs containing a function pointer and captured environment.
Backendclosuresescape analysis
0 likes · 6 min read

This article compares how Java, Groovy, Python, and Go implement closures and treat functions as parameters, showing concrete syntax for defining single‑parameter, multi‑parameter, and parameter‑less closures, as well as returning and invoking them within methods.
GroovyPythonclosures
0 likes · 7 min read

This article explains the most frequent Python traps—such as mutable default arguments, subtle differences between x+=y and x=y+y, tuple syntax, list mutability, iteration pitfalls, closure binding, import quirks, version incompatibilities, and GIL—providing clear examples and practical solutions.
Pythonbest-practicesbugs
0 likes · 13 min read

This article enumerates frequent Python pitfalls—including UnboundLocalError, mutable default arguments, subtle differences between x+=y and x=x+y, tuple syntax, shared mutable containers, list mutation during iteration, closure late binding, misuse of del, import inconsistencies, version‑specific changes, and the GIL—providing explanations and correct practices to help developers write safer code.
GILVersion Compatibilityclosures
0 likes · 13 min read

This article explains PHP anonymous functions (closures), demonstrating how to reference local variables with the use keyword, embed anonymous functions within regular functions, return them, pass parameters, and use them as arguments, accompanied by clear code examples.
Anonymous Functionscallbacksclosures
0 likes · 2 min read

This article explains a Python puzzle where a list of lambda functions unexpectedly returns [6,6,6,6] due to late binding in closures, walks through the code, debugging screenshots, and clarifies how closures capture loop variables in Python.
Pythonclosureslist comprehension
0 likes · 6 min read
![Unraveling Why Python’s Lambda Returns [6,6,6,6] – A Closure Deep Dive](https://wsrv.nl/?url=http%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FicjSAZybsq56FqxLHlfuaXdcY0RJicUzS23ff3XiadnIh2ApKRGMbeDv82E3X78ibICvoEpriaXFJoB2MVNFSGZWOsw%2F0%3Fwx_fmt%3Dpng)
This article explains Python closures and decorators, illustrating how closures capture free variables and how decorators can wrap functions to log calls, handle parameters, and preserve metadata, with clear code examples and step‑by‑step explanations.
Pythonclosuresdecorators
0 likes · 5 min read

This article introduces Groovy closures, explaining their definition, implicit 'it' parameter, custom arguments, return behavior, and demonstrates how to assign, invoke, and pass closures to methods such as each() and findAll() for list processing, accompanied by practical code examples.
Groovyclosureslist processing
0 likes · 5 min read

This article surveys typical Python traps—including UnboundLocalError, mutable default arguments, in‑place versus out‑of‑place updates, tuple syntax, shared mutable containers, list mutation during iteration, closure late binding, __del__ pitfalls, import inconsistencies, version differences, operator quirks, attribute magic methods, and the GIL—explaining why they occur and offering safe alternatives.
GILPythonattribute-access
0 likes · 12 min read

The article surveys functional programming fundamentals—contrasting it with imperative and declarative styles—and illustrates key concepts such as closures, currying, promises, partial functions, map/reduce, and divmod through Java, JavaScript, and Python examples, before highlighting Scala’s hybrid approach and the advantages of FP for writing elegant, maintainable, concurrent code.
Programming ParadigmsPromisesScala
0 likes · 12 min read


政采云技术Aug 22, 2019 · Frontend Development
This article provides a comprehensive guide to JavaScript functions, covering their various forms, execution contexts, scope chains, arguments handling, return values, the dynamic this keyword, and advanced functional programming techniques such as currying, decoration, and function composition.
CompositionCurryingJavaScript
0 likes · 54 min read

This article explains ten subtle Python pitfalls—including UnboundLocalError, mutable default arguments, the difference between x += y and x = x + y, tuple syntax, list‑of‑lists initialization, modifying a list while iterating, closure‑late binding with lambdas, __del__ interactions with garbage collection, inconsistent module imports, Python‑2‑to‑3 migration quirks, and the Global Interpreter Lock—providing clear examples and recommended fixes.
closuresmutable-default-argspitfalls
0 likes · 12 min read

This article walks through seven tricky Python snippets—default mutable arguments, lambda closures, class variable inheritance, division differences between Python 2 and 3, out‑of‑range slicing, list multiplication side effects, selective list comprehensions, and custom dict subclasses—explaining their outputs and how to fix them.
Class Variablesclosuresdefault-arguments
0 likes · 12 min read

An unexpected Python interview question demonstrates how late binding in closures causes all lambdas to use the final loop value, producing 6,6,6,6 instead of 0,2,4,6, and the article explains the underlying reason and presents four practical solutions to achieve the intended output.
FunctionPythonclosures
0 likes · 4 min read

This article explains why mutable default arguments share state, how Python closures cause late binding issues, the inheritance rules of class variables, differences between division operators in Python 2 and 3, list slicing behavior, list multiplication references, list comprehensions for even-indexed values, and custom dict subclasses with __missing__.
Class VariablesPythonclosures
0 likes · 11 min read

The article examines a Python interview question where a lambda list inside a loop unexpectedly prints 6 for all elements due to late binding in closures, explains the underlying mechanism, and presents four practical solutions—including default‑argument binding, functools.partial, generator expressions, and yield‑based approaches—to achieve the intended 0, 2, 4, 6 output.
closuresinterview questionlambda
0 likes · 5 min read

This article explains what anonymous functions (closures) are in PHP, how Laravel leverages them for dynamic service registration, and demonstrates their usage with a concrete example from the framework’s service provider code.
Anonymous FunctionsLaravelPHP
0 likes · 2 min read

This article walks through several puzzling Python code snippets, explaining why default mutable arguments share state, how closures suffer from late binding, the inheritance of class variables, differences in division between Python 2 and 3, list slicing quirks, and how list multiplication creates shared references, while also offering corrected implementations.
Class VariablesPythonclosures
0 likes · 12 min read

This article explains Kotlin's function syntax, special return types Unit and Nothing, nested functions, operator overloading, infix expressions, closures, self‑executing closures, lambda expressions, higher‑order functions, and inline functions, illustrating each concept with clear code examples.
KotlinLambdasclosures
0 likes · 11 min read

This article explores every essential aspect of JavaScript functions—from declarations, expressions, anonymous callbacks, and self‑executing IIFEs to parameter passing, functional programming concepts, closures, and advanced module patterns—providing clear explanations, diagrams, and code examples to help developers build solid foundations.
IIFEclosuresfrontend
0 likes · 14 min read

This article explains Python functions in depth, covering their definition with def, parameter handling including default, variable-length, and keyword arguments, the role of return statements, scope rules, inner functions and closures, anonymous lambda expressions, and the built‑in filter function, illustrated with clear diagrams.
Pythonclosuresfilter
0 likes · 7 min read

JavaScript functional programming, once a niche topic, has surged in popularity since ES6, and this article explores practical implementations—showcasing functional code versus traditional approaches, benefits like clearer semantics and reusability, common models such as closures, higher‑order functions, currying, and composition, plus optimization techniques.
CompositionCurryingJavaScript
0 likes · 12 min read


21CTOFeb 27, 2017 · Backend Development
PHP7 brings a host of performance improvements and new language features—including refined namespace usage, interfaces, traits, generators, closures, Zend OPcache, and a built‑in HTTP server—each illustrated with practical code examples and best‑practice recommendations for modern backend development.
OPcacheTraitsbackend development
0 likes · 8 min read

This article explains JavaScript closures, covering variable scope, how closures bridge inner and outer functions, and demonstrates practical uses such as creating private/public scopes and correctly attaching DOM event handlers in loops, with clear code examples and visual illustrations.
DOM EventsJavaScriptclosures
0 likes · 4 min read

This article introduces the latest PHP language features—including namespaces, traits, closures, generators, and a range of new syntax enhancements—explaining their purpose, usage, and code examples to help developers build modern, maintainable web applications.
PHPTraitsbackend development
0 likes · 17 min read
