Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #112169
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: Scope of identifiers |
| Date | Wed, 14 Jun 2017 21:53:10 +1200 |
| Lines | 57 |
| Message-ID | <eqcfc6F6167U4@mid.individual.net> (permalink) |
| References | <ohmea9$nft$1@gioia.aioe.org> <lnink1gnzy.fsf@kst-u.example.com> <081872d4-3f9d-0004-8c0d-25a274bba7bb@verizon.net> <ln60g1gfmy.fsf@kst-u.example.com> <e74c416a-d6e4-7f4d-e939-ec5f0cfd010b@verizon.net> <lnwp8hez7v.fsf@kst-u.example.com> <eb8fd32a-b3d5-4767-8a78-3d85ade2fc92@googlegroups.com> <ln60fzg0la.fsf@kst-u.example.com> <e3512b0c-6925-4ef8-ae8b-f142f2de4fc3@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net mLvsjvBOGZ+4VUwWKrU+uwsrL5DvUpSrr/8iD9c+PeCB50PX7r |
| Cancel-Lock | sha1:qN7IHXv0DFJcUyjY5CSejoG7HDg= |
| User-Agent | Mozilla/5.0 (X11; SunOS i86pc; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
| In-Reply-To | <e3512b0c-6925-4ef8-ae8b-f142f2de4fc3@googlegroups.com> |
| Xref | csiph.com comp.lang.c:112169 |
Show key headers only | View raw
On 06/14/17 04:02 PM, David Kleinecke wrote:
> On Tuesday, June 13, 2017 at 12:16:26 PM UTC-7, Keith Thompson wrote:
>> David Kleinecke <dkleinecke@gmail.com> writes:
>>> On Monday, June 12, 2017 at 1:19:09 PM UTC-7, Keith Thompson wrote:
>> [...]
>>>> What I proposed was to replace the current definition of "same scope"
>>>> (which is problematic because two non-identical scopes can be the "same
>>>> scope") by something like "matching scope". (I'm open to a better
>>>> adjective than "matching".) I think that solves the (minor) problem of
>>>> "same scope" being confusing, it doesn't add to the number of defined
>>>> terms, and it's a fairly minimal change.
>>>
>>> If one looks at the case of block scope and the old C approach
>>> one observes that all the declarations come before the statements.
>>> If one thinks of "starting" a scope extends through all the
>>> declarations then a single concept of "scope" holds.
>>>
>>> This observation doesn't help the present day situation but it does
>>> help explain how the situation cam about.
>>
>> Given:
>>
>> {
>> int a = 10;
>> int b = a;
>> int c = d; /* illegal */
>> int d = 20;
>> /* statements ... */
>> }
>>
>> the initialization of c is invalid because the scope of d doesn't start
>> until the line on which it's defined.
>>
>> The lifetimes of all 4 objects begin at the same time, when
>> execution reaches the opening "{", but their scopes begin at 4
>> different locations. All 4 scopes are the "same scope" as the
>> standard defines that phrase. (Scope is a compile-time concept;
>> lifetime is a run-time concept.)
>>
>> [...]
>
> OK if you want to get pedantic.
This is Usenet...
> In the sense of the statements -
> all the declarations happen first. They generally are such that
> they can be freely shuffled around. C has taken advantage of the
> fact that they have to be declared in some order to introduce
> more flexibility. It can be argued that initialization is a bad
> idea and should be avoided and if there are no initializations
> the declarations can be made in any order.
I don't see why, why should the order be important?
--
Ian
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Scope of identifiers Steve Keller <keller@no.invalid> - 2017-06-12 18:08 +0200
Re: Scope of identifiers "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 12:22 -0400
Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 09:39 -0700
Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 09:38 -0700
Re: Scope of identifiers "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 14:41 -0400
Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 12:39 -0700
Re: Scope of identifiers "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 15:53 -0400
Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-12 13:19 -0700
Re: Scope of identifiers David Kleinecke <dkleinecke@gmail.com> - 2017-06-13 11:01 -0700
Re: Scope of identifiers jameskuyper@verizon.net - 2017-06-13 11:25 -0700
Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-13 12:16 -0700
Re: Scope of identifiers David Kleinecke <dkleinecke@gmail.com> - 2017-06-13 21:02 -0700
Re: Scope of identifiers Ian Collins <ian-news@hotmail.com> - 2017-06-14 21:53 +1200
Re: Scope of identifiers supercat@casperkitty.com - 2017-06-14 08:10 -0700
Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-14 09:19 -0700
Re: Scope of identifiers supercat@casperkitty.com - 2017-06-14 10:14 -0700
Re: Scope of identifiers Keith Thompson <kst-u@mib.org> - 2017-06-14 09:12 -0700
Re: Scope of identifiers Robert Wessel <robertwessel2@yahoo.com> - 2017-06-12 13:02 -0500
csiph-web