Shadowing
Shadowing is the concealment of an existing name binding or inherited property by a nearer declaration or property with the same name.
100 C++ Mistakes and How to Avoid Them
Variable shadowing occurs when a declaration in an inner scope uses the same name as a declaration in an outer scope, hiding the outer declaration within the inner scope.
- How it is used
- Uses shadowing to expose correctness and readability risks in class operations and legacy-style C++ code.
- How deep it goes
- Defines overlapping scopes, demonstrates a setter failure, and recommends explicit qualification and naming; it does not develop formal scope internals.
- Examples
- Uses Circle radius members and parameters, namespace-qualified globals, and an Analyzer constructor with similarly named values.
- What you can do after
- Diagnose shadowing by tracing scopes and correct it with clearer names, this qualification, or namespace qualification.
Read how 100 C++ Mistakes and How to Avoid Them explains shadowing →
The Well-Grounded Python Developer: How the pros use Python and Flask
Shadowing is the concealment of an existing name binding by another binding with the same name in a nearer or overriding namespace.
- How it is used
- Warns against accidental name collisions and motivates namespaces for organizing reusable Python functionality.
- How deep it goes
- Explains replacement and namespace separation through built-in and module examples, but does not catalog broader name-resolution rules.
- Examples
- Uses open(), duplicate add() functions, utility.add(), aliased imports, and qualified module calls.
- What you can do after
- Diagnose/debug with it by spotting hidden built-ins or overwritten functions and separating conflicting definitions into module namespaces.
Read how The Well-Grounded Python Developer: How the pros use Python and Flask explains shadowing →
Learn Rust in a Month of Lunches
Shadowing is the Rust language feature that creates a new variable with the same name as an existing variable, hiding the earlier binding within the current scope.
- How it is used
- Uses repeated bindings to transform values, change types, and keep intermediate names out of short calculations.
- How deep it goes
- Defines bindings, scopes, mutability differences, and references, but stops short of deeper ownership mechanics.
- Examples
- Demonstrates integer-to-float rebinding, nested blocks, arithmetic transformations, and a reference surviving shadowing.
- What you can do after
- Apply shadowing in Rust to reuse clear names, transform values, and distinguish hidden bindings from mutable ones.
Read how Learn Rust in a Month of Lunches explains shadowing →
100 Go Mistakes and How to Avoid Them
A shadowed variable is a variable declaration that hides another variable with the same name in an enclosing scope.
- How it is used
- Uses shadowing to diagnose initialization mistakes and improve Go code organization.
- How deep it goes
- Defines scope and shadowing, traces a nil result, and compares temporary-variable and direct-assignment fixes.
- Examples
- Uses tracing-dependent HTTP client creation to show hidden declarations and two corrected initialization patterns.
- What you can do after
- Diagnose hidden declarations and choose temporary-variable or direct-assignment fixes for conditional initialization.
Read how 100 Go Mistakes and How to Avoid Them explains shadowing →
Related concepts
- statecontrasts with · State is information or a configuration describing the condition of a system, entity, or computation at a particular time and potentially influencing subsequent behavior or decisions.
- let keyworduses · A let construct is a language feature that introduces a name binding associating an identifier with a value or expression.
- scope resolution operatorused by · A scope resolution operator is syntax that qualifies a name by specifying an enclosing namespace, class, module, or other scope.
- scopeuses · Scope is the region of a program in which names are visible and can be resolved according to the language’s lookup rules.
- namespaceaddressed by · A namespace is a naming context or identifier space in which names are defined and resolved, distinguishing them from names in other contexts.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



