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 →
JavaScript in Depth
The condition in which an object's own property takes precedence over an inherited property with the same name.
- How it is used
- Explains why object reads and writes produce different results across a prototype chain.
- How deep it goes
- Traces data properties, accessors, setters, and prototype traversal, while deferring broader prototype-pollution treatment.
- Examples
- Uses drawer objects, inherited labels, accessor-backed labels, authorization checks, and configuration defaults.
- What you can do after
- Diagnose unexpected property values by separating own data properties from inherited properties and setters.
Also covered in
- Go in Action, Second Edition
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
- Idiomatic Rust
- Julia as a Second Language
- Tiny Python Projects: Learn coding and testing with puzzles and games
- Clojure: The Essential Reference
- Essential TypeScript 5, Third Edition
What to know first
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- MapA map is an associative data structure that stores key-value associations and supports retrieving values by key.
- listA list is an ordered collection of elements arranged in a sequence.
- bindingName binding is the association of an identifier with the program entity or value it denotes.
Related concepts
- statecontrasts with · State is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
- 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 to their bindings according to the language’s rules.
- blockuses · A code block is a grouped region of code treated as a unit, with boundaries and scope or execution behavior determined by its language or context.
Questions about shadowing
What is shadowing?
Shadowing is the concealment of an existing name binding or inherited property by a nearer declaration or property with the same name.
Which Manning books explain shadowing?
100 C++ Mistakes and How to Avoid Them, The Well-Grounded Python Developer: How the pros use Python and Flask, Learn Rust in a Month of Lunches, 100 Go Mistakes and How to Avoid Them and JavaScript in Depth.
What should I know before learning shadowing?
Manning books that teach shadowing usually introduce function, Map, list and binding first.
What is the difference between shadowing and state?
Shadowing is the concealment of an existing name binding or inherited property by a nearer declaration or property with the same name. State is information describing the condition or configuration of a system or computation at a particular time that may influence its behavior or subsequent transitions.
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.




