Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #59064

Re: Lexical Variables In C Loops (As Compared To Perl Loops)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Lexical Variables In C Loops (As Compared To Perl Loops)
Date Thu, 26 Mar 2015 23:38:48 -0700
Organization None to speak of
Lines 24
Message-ID <877fu3ndvr.fsf@kst-u.example.com> (permalink)
References <ZK2dnYy7U9u2vpDInZ2dnUVZ57ydnZ2d@giganews.com> <mek71u$ai7$1@dont-email.me> <MPG.2f776e088e8f86712@news.eternal-september.org> <mengou$omv$1@dont-email.me> <H7ednfaII6GSd4nInZ2dnUVZ572dnZ2d@giganews.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="c77ff4d35e33d1c939d3461ebde8dd0d"; logging-data="23889"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195YWowjnExWNpYFrAoTQHo"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Cancel-Lock sha1:z1x6RhM815fXKMELKZBbbYTgMlk= sha1:sJNZJavpi63YVetVrEhT5p4CfVQ=
Xref csiph.com comp.lang.c:59064

Show key headers only | View raw


Robbie Hatley <see.my.sig@for.my.address> writes:
[...]
> Perl is ref-counted, so if you repeatedly alter a variable, save
> a reference, alter the variable, save a reference, etc, during a
> loop, then multiple "snapshots" of the variable will be created.
> When the loop exists, the variable goes out of scope. BUT, the
> snapshots remain, and the references you saved all point towards
> those valid referents. Only when the references themselves go out
> of scope will the referents be trashed by the garbage collector.

That's true if the variable is defined inside the loop.  Each iteration
creates a new object, and saving a reference to it keeps it from
vanishing.

If the variable is defined outside the loop, grabbing a reference inside
the loop just gives you multiple references to the same object.

(Reminder: I'm talking about Perl, not C.)

-- 
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 | Find similar | Unroll thread


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