Topic: Is block scope defined in the standard?


Author: v.Abazarov@comAcast.net (Victor Bazarov)
Date: Thu, 26 Aug 2004 06:43:47 GMT
Raw View
kanze@gabi-soft.fr wrote:
> In =A77.1.2/3, there is a sentence: "The inline specifier shall not app=
ear
> on a block scope function declaration."  Where is "block scope" defined=
?
> Or is this a slip-up, and what is meant is "local scope"?

See 6.3 for the definition of "block".  "Block scope" is scope limited
to a block.

Victor

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: llewelly.at@xmission.dot.com (llewelly)
Date: Thu, 26 Aug 2004 06:55:29 GMT
Raw View
kanze@gabi-soft.fr writes:

> In =A77.1.2/3, there is a sentence: "The inline specifier shall not app=
ear
> on a block scope function declaration."  Where is "block scope" defined=
?
> Or is this a slip-up, and what is meant is "local scope"?

I think it means local scope;=20

6.3/1:   =20
   =20
    # So that several statements can be used where one is expected,
    # the compound statement (also, and equivalently, called "block")
    # is provided.
    #
    #       compound-statement:
    #                     { statement-seqopt }
    #       statement-seq:
    #                   statement
    #                   statement-seq statement
    #
    # A compound statement defines a local scope (3.3). [Note: a
    # declaration is a statement (6.7). ]

3.3.2 also supports the same notion, but, like 6.3/1, without
    referring to 'block scope' directly.

There's no defintion of 'block scope' in the standard, but if its use
    is a slip-up, it was made all over the place; I see it in:=20
   =20
    3.3.1/6
    3.4.1/6
    3.4.1/8=20
    3.5/6
    3.5/7
    3.6.3/1
    7.1.1/2
    7.1.2/3
    7.3.3/11
    7.3.4
    9.5/3
    20.4.5/1

I imagine 'block scope' has such a long lineage in the C and C++
    communities that WG21 thought no-one would question its
    meaning. :-)=20

As far as I can tell, none of these paragraphs would change meaning
    if 'block scope' were replaced with 'local scope' .

There's a defintion of block scope in C99:

6.2.1/4:

    # [...] If the declarator or type specifier that declares the
    # identifier appears inside a block or within the list of
    # parameter declarations in a function definition, the identifier
    # has block scope, which terminates at the end of the associated
    # block. [...]

I believe this definition is consistent with the usages in C++98, and
    I'm sure the C99 and C++98 notions of block scope share a common
    ancestor, but C++ and C name lookup rules differ enough that I am
    not entirely saguine about relying on a C definition for 'block
    scope'.

Possibly someone should submit a defect report with a suggested
    resolution along the lines of:

    6.3/2 (new paragraph)
        The terms 'block scope' and 'local scope' are synonymous.

Alternativly, replace all occurances of 'block scope' with 'local
    scope' .
   =20

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kanze@gabi-soft.fr
Date: Thu, 26 Aug 2004 19:27:24 GMT
Raw View
llewelly.at@xmission.dot.com (llewelly) wrote in message
news:<86smaabeq6.fsf@Zorthluthik.local.bar>...
> kanze@gabi-soft.fr writes:

> > In 7.1.2/3, there is a sentence: "The inline specifier shall not app
> > ear on a block scope function declaration."  Where is "block scope"
> > defined ?  Or is this a slip-up, and what is meant is "local scope"?

> I think it means local scope;

I'm pretty sure that that is the intent.  In practice, I considered
three possibilities:

  - block scope is defined somewhere in the standard as a synonym for
    local scope, and I missed it,

  - local scope was meant, but someone got careless and used the wrong
    words, or

  - block scope actually was defined as something different somewhere
    that I'd missed, and there was still something else in C++ that
    didn't work like I thought.

To tell the truth, in this case, I had pretty much discounted the last
possibility.

    [...]
> There's no defintion of 'block scope' in the standard, but if its use
>     is a slip-up, it was made all over the place; I see it in:

>     3.3.1/6
>     3.4.1/6
>     3.4.1/8
>     3.5/6
>     3.5/7
>     3.6.3/1
>     7.1.1/2
>     7.1.2/3
>     7.3.3/11
>     7.3.4
>     9.5/3
>     20.4.5/1

> I imagine 'block scope' has such a long lineage in the C and C++
>     communities that WG21 thought no-one would question its
>     meaning. :-)

Which isn't good enough for a standard.

    [...]
> Possibly someone should submit a defect report with a suggested
>     resolution along the lines of:

>     6.3/2 (new paragraph)
>         The terms 'block scope' and 'local scope' are synonymous.

> Alternativly, replace all occurances of 'block scope' with 'local
>     scope' .

That sounds about right.  I don't like the idea of synonyms, but there
is a precedent (integer type and integral type), and that way, we are
sure we don't miss one.

--
James Kanze           GABI Software         http://www.gabi-soft.fr
Conseils en informatique orient   e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S   mard, 78210 St.-Cyr-l'   cole, France, +33 (0)1 30 23 00 34

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kanze@gabi-soft.fr
Date: Wed, 25 Aug 2004 04:28:05 GMT
Raw View
In    7.1.2/3, there is a sentence: "The inline specifier shall not appear
on a block scope function declaration."  Where is "block scope" defined?
Or is this a slip-up, and what is meant is "local scope"?

--
James Kanze           GABI Software         http://www.gabi-soft.fr
Conseils en informatique orient   e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S   mard, 78210 St.-Cyr-l'   cole, France, +33 (0)1 30 23 00 34

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: invalid@bigfoot.com (Bob Hairgrove)
Date: Thu, 26 Aug 2004 00:05:35 GMT
Raw View
On Wed, 25 Aug 2004 04:28:05 GMT, kanze@gabi-soft.fr wrote:

>In =A77.1.2/3, there is a sentence: "The inline specifier shall not appe=
ar
>on a block scope function declaration."  Where is "block scope" defined?
>Or is this a slip-up, and what is meant is "local scope"?

See:
6.3, "Compound statement or block"

   and

3.3.2, "Local scope"


--
Bob Hairgrove
NoSpamPlease@Home.com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: petebecker@acm.org (Pete Becker)
Date: Thu, 26 Aug 2004 06:27:55 GMT
Raw View
kanze@gabi-soft.fr wrote:
>=20
> In =A77.1.2/3, there is a sentence: "The inline specifier shall not app=
ear
> on a block scope function declaration."  Where is "block scope" defined=
?
> Or is this a slip-up, and what is meant is "local scope"?
>=20

I found 20 uses of "block scope" in the standard. None of them is a
definition.

--=20

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]