Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Lexical Variables In C Loops (As Compared To Perl Loops) |
| Date | 2015-03-22 20:08 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <menlfj$bbj$1@dont-email.me> (permalink) |
| References | <ZK2dnYy7U9u2vpDInZ2dnUVZ57ydnZ2d@giganews.com> <mek71u$ai7$1@dont-email.me> <MPG.2f776e088e8f86712@news.eternal-september.org> <mengou$omv$1@dont-email.me> <87384wvbyp.fsf@kst-u.example.com> |
On 03/22/2015 07:39 PM, Keith Thompson wrote: > James Kuyper <jameskuyper@verizon.net> writes: >> On 03/21/2015 04:01 PM, Philip Lantz wrote: > [...] >>> The difference between C and Perl is that in C the lifetime of the >>> variable always ends at the end of each iteration of the loop, whereas >>> in Perl the lifetime of the variable may extend beyond the end of the >>> iteration of the loop in which it was allocated (and does, in this >>> example). >> >> Can you refer to $var after the end of the loop? If only the memory >> persists, rather than access to that memory through the variable name, >> then you can't properly say that the variable persists. If you can >> access the memory through $var after the loop, which of the ten >> different addresses given does it refer to? > > What exactly do you mean by the word "variable"? ... A named object. I can cite support for that definition from the C++ standard (3p6), though that definition is far more complex than mine. However, I'll freely admit that the C standard provides no such definition. It's just my personal definition, though I did check many uses of the term as a noun in the C standard, and they all seemed consistent with that definition (the C standard uses "variable" as an adjective far more often than as a noun, which makes the search difficult). > ... The C standard doesn't > define it, so there's no definitive answer. The way I use it, the word > "variable" is nearly synonymous with "object", except that not all > objects are variables. In that sense, I'd say that $var can persist > outside the loop, even if it's not visible by that name. As a "named object", it ceases to qualify as a variable when the connection to it's name is no longer usable. -- James Kuyper
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Lexical Variables In C Loops (As Compared To Perl Loops) Robbie Hatley <see.my.sig@for.my.address> - 2015-03-21 00:52 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Richard Heathfield <rjh@cpax.org.uk> - 2015-03-21 08:28 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Robbie Hatley <see.my.sig@for.my.address> - 2015-03-26 20:57 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Keith Thompson <kst-u@mib.org> - 2015-03-21 01:29 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Robbie Hatley <see.my.sig@for.my.address> - 2015-03-26 21:01 -0700
Lexical Variables In C Loops (As Compared To Perl Loops) asetofsymbols@gmail.com - 2015-03-21 01:40 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) jt@toerring.de (Jens Thoms Toerring) - 2015-03-21 08:43 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Robbie Hatley <see.my.sig@for.my.address> - 2015-03-26 20:58 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Richard Heathfield <rjh@cpax.org.uk> - 2015-03-27 06:12 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Keith Thompson <kst-u@mib.org> - 2015-03-26 23:32 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Bartc <bc@freeuk.com> - 2015-03-21 10:54 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Keith Thompson <kst-u@mib.org> - 2015-03-21 13:54 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Robbie Hatley <see.my.sig@for.my.address> - 2015-03-26 21:24 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-03-27 20:35 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Bartc <bc@freeuk.com> - 2015-03-27 21:24 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-03-28 00:03 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Bartc <bc@freeuk.com> - 2015-03-28 10:00 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Stephen Sprunk <stephen@sprunk.org> - 2015-03-28 18:14 -0500
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Kaz Kylheku <kaz@kylheku.com> - 2015-03-21 14:39 +0000
Re: Lexical Variables In C Loops (As Compared To Perl Loops) fir <profesor.fir@gmail.com> - 2015-03-21 09:40 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) James Kuyper <jameskuyper@verizon.net> - 2015-03-21 12:43 -0400
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Philip Lantz <prl@canterey.us> - 2015-03-21 13:01 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) James Kuyper <jameskuyper@verizon.net> - 2015-03-22 18:47 -0400
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Keith Thompson <kst-u@mib.org> - 2015-03-22 16:39 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) James Kuyper <jameskuyper@verizon.net> - 2015-03-22 20:08 -0400
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Robbie Hatley <see.my.sig@for.my.address> - 2015-03-26 22:36 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Keith Thompson <kst-u@mib.org> - 2015-03-26 23:40 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Robbie Hatley <see.my.sig@for.my.address> - 2015-03-26 22:26 -0700
Re: Lexical Variables In C Loops (As Compared To Perl Loops) Keith Thompson <kst-u@mib.org> - 2015-03-26 23:38 -0700
csiph-web