I have been trying to understand what it means to say "scope of a named entity". In reading about scope, there are terms like visibility, lifetime, accessibility and more that are used. What is confusing is the fact that the terms are at times used distinctly and at times interchangeably.
Quoting from this IBM article:
scope is... the largest region in which the name potentially is valid.
Fair enough. But then what does this mean -
The visibility of an identifier is the region of program text from which the object associated with the identifier can be legally accessed.
Is visibility related to accessibility?
Further it goes on to say
Scope exceeds visibility when a duplicate identifier is used in an inner declarative region, thereby hiding the object declared in the outer declarative region. The original identifier cannot be used to access the first object until the scope of the duplicate identifier (the lifetime of the second object) has ended.
Does this mean scope and lifetime are the same things?
Do these terms like scope fundamentally mean the same thing in C++ as it does in say PHP or Python or even Java. Or they could mean different things conceptually depending on the language you are working in. The article I have quoted is C/C++ related, but I want to understand the terms in the general sense.