Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #112196
| 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 | Wed, 14 Jun 2017 09:19:14 -0700 |
| Organization | None to speak of |
| Lines | 45 |
| Message-ID | <lnd1a6ee4d.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> <ln60fzg0la.fsf@kst-u.example.com> <e3512b0c-6925-4ef8-ae8b-f142f2de4fc3@googlegroups.com> <e60a5ee2-13c8-4326-b9e6-9055bdd69b25@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="96bbf95725af2559ab0735ee54475e20"; logging-data="28600"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19r4WV7RkwNRPb5lKlCJlB1" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:J2T5ri+k9SYlFEQAqVbfiPv2VsI= sha1:ebGon48aXih3Amhoj/NhzMY5Zk8= |
| Xref | csiph.com comp.lang.c:112196 |
Show key headers only | View raw
supercat@casperkitty.com writes:
> On Tuesday, June 13, 2017 at 11:02:59 PM UTC-5, David Kleinecke wrote:
>> In other words in a primitive pre-C there was no initialization
>> and the declarations could be thought of as simultaneous and all
>> the scopes as the same. This simplicity is lost when initialization
>> was introduced.
>
> Under C89, a single-pass implementation given:
>
> int x = expressionYieldingLotsOfCode;
> int y;
>
> could generate code:
>
> bump stack pointer to leave space for x
> evaluate expresstionYieldingLotsOfCode
> bump stack pointer to leave space for y
>
> The compiler wouldn't need to know about y, or much space it would take,
> when generating code for the big expression. Under C99, however, a
> compiler has to handle:
>
> someLabel:
> arbitraryStatement;
> int x = expressionYieldingLotsOfCode;
> int y;
>
> If jumping before a declaration would end a variable's lifetime, an
> implementation could simply precede the jump with code that would reset
> the stack pointer to the value it had the first time it ran the
> arbitrary statement. Under C99 rules, however, space would need to
> remain reserved for y the second time the code runs.
Under C90, as under C99, the lifetime of an object with automatic
storage duration begins on entry to the enclosing block.
A C90 compiler could defer allocation until control reaches the
declaration, but that's an optimization, not part of the visible
semantics. A C99 compiler can perform exactly the same optimization
if there are no labels preceding the declaration.
--
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