Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   visibility, declarative region, scope, validity, introduction and accessibility (http://www.velocityreviews.com/forums/t459166-visibility-declarative-region-scope-validity-introduction-and-accessibility.html)

Steven T. Hatton 12-13-2006 05:54 AM

visibility, declarative region, scope, validity, introduction and accessibility
 
All of the following terms are used in some way to describe where and how a
name is relevant to a particular location in a program: visible,
declarative region, scope, potential scope, valid, introduced, used,
potentially evaluated and accessible. They all seem to have subtle
difference in meanings.

Any positive contribution to the following will be appreciated.

Here is my attempt to make sense of these:

*)declarative region
The declarative region of a name is largest "containment" construct (block,
namespace or class) in which the name is valid. A declarative region which
is not global[1] is delimited by '{' and '}'. There may be more than one
such delimited construct composing a declarative region.

*)valid
Valid seems to mean "in scope", but I'm not sure if that is sufficient or
correct.

*)potential scope
The part of a program beginning immediately after the first point of
declaration of a name, and extending to the end of the name's declarative
region.

*)scope
The portion of the potential scope excluding any potential scope determined
by declaring the same name in an enclosed declarative region. [2]

*)introduced
A name is introduced into a declarative region by a declaration which makes
it valid[3] within that declarative region.

*)accessible
It's got to do with public, protected, private and friend, but I don't know
how best to put it into words.

*)visible
A name is visible if it is in scope and not hidden. A name may be visible,
and not accessible. I'm not sure of the consequences of that, however.

*)potentially evaluated
"An expression is potentially evaluated unless
**)it appears where an integral constant expression is required (see 5.19),
**)is the operand of the sizeof operator (5.3.3),
**)or is the operand of the typeid operator and the expression does not
designate an lvalue of polymorphic class type (5.2.8)."


*)used
"An expression is potentially evaluated unless it appears where an integral
constant expression is required (see 5.19), is the operand of the sizeof
operator (5.3.3), or is the operand of the typeid operator and the
expression does not designate an lvalue of polymorphic class type (5.2.8)."

[1]Is a translation unit a declarative region?

[2]The Standard says: "The scope of a declaration is the same as its
potential scope unless the potential scope contains another declaration of
the same name." I believe there is a subtle error in that statement. To
wit, a name may be redeclared in the same declarative region in which it
was originally declared, and the scope would not be affected.

[3]The definition is circular.
--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/

Steven T. Hatton 12-13-2006 06:29 AM

Re: visibility, declarative region, scope, validity, introduction and accessibility
 
Steven T. Hatton wrote:

> All of the following terms are used in some way to describe where and how
> a name is relevant to a particular location in a program: visible,
> declarative region, scope, potential scope, valid, introduced, used,
> potentially evaluated and accessible. They all seem to have subtle
> difference in meanings.
>
> Any positive contribution to the following will be appreciated.
>
> Here is my attempt to make sense of these:
>
> *)declarative region
> The declarative region of a name is largest "containment" construct
> (block,
> namespace or class) in which the name is valid. A declarative region
> which
> is not global[1] is delimited by '{' and '}'. There may be more than one
> such delimited construct composing a declarative region.
>
> *)valid
> Valid seems to mean "in scope", but I'm not sure if that is sufficient or
> correct.
>
> *)potential scope
> The part of a program beginning immediately after the first point of
> declaration of a name, and extending to the end of the name's declarative
> region.
>
> *)scope
> The portion of the potential scope excluding any potential scope
> determined by declaring the same name in an enclosed declarative region.
> [2]
>
> *)introduced
> A name is introduced into a declarative region by a declaration which
> makes it valid[3] within that declarative region.
>
> *)accessible
> It's got to do with public, protected, private and friend, but I don't
> know how best to put it into words.
>
> *)visible
> A name is visible if it is in scope and not hidden. A name may be
> visible,
> and not accessible. I'm not sure of the consequences of that, however.
>
> *)potentially evaluated
> "An expression is potentially evaluated unless
> **)it appears where an integral constant expression is required (see
> 5.19), **)is the operand of the sizeof operator (5.3.3),
> **)or is the operand of the typeid operator and the expression does not
> designate an lvalue of polymorphic class type (5.2.8)."
>
>
> *)used
> "An expression is potentially evaluated unless it appears where an
> integral constant expression is required (see 5.19), is the operand of the
> sizeof operator (5.3.3), or is the operand of the typeid operator and the
> expression does not designate an lvalue of polymorphic class type
> (5.2.8)."
>
> [1]Is a translation unit a declarative region?


The following excerpt from the first example in 3.3.5 indicates to me that
the bounds of a translation unit do not delimit declarative regions. The
unnamed namespace is introduced in order to establish that delimitation.

namespace N {
int i;
int g(int a) { return a; }
int j();
void q();
}
namespace { int l=1; }
// the potential scope of l is from its point of declaration
// to the end of the translation unit


> [2]The Standard says: "The scope of a declaration is the same as its
> potential scope unless the potential scope contains another declaration of
> the same name." I believe there is a subtle error in that statement. To
> wit, a name may be redeclared in the same declarative region in which it
> was originally declared, and the scope would not be affected.
>
> [3]The definition is circular.


--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/


All times are GMT. The time now is 02:02 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.