liveBook · Manning

Shadowing

Shadowing is the concealment of an existing name binding or inherited property by a nearer declaration or property with the same name.

How 5 Manning books explain it

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.

Read how JavaScript in Depth explains shadowing →

Also covered in

What to know first

Related concepts

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.