Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #112127
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <kst-u@mib.org> |
| Newsgroups | comp.lang.c |
| Subject | Re: Scope of identifiers |
| Date | Tue, 13 Jun 2017 12:16:17 -0700 |
| Organization | None to speak of |
| Lines | 44 |
| Message-ID | <ln60fzg0la.fsf@kst-u.example.com> (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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="3c5458cd01e27031549862a8458a90ae"; logging-data="3072"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18T2Eug9RuvkyF37YRh/8qC" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:LdJdE5MMfdjgkQFugobKkh7Wlag= sha1:jKuovUOqAcik9A0XxANHA4w9GsU= |
| Xref | csiph.com comp.lang.c:112127 |
Show key headers only | View raw
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.)
[...]
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
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