Re: Persisting Values Across Method Calls

2001-11-02 Thread Jeff 'japhy' Pinyan
On Nov 2, Paul Johnson said: >{ my $a = "foo"; sub foo { sub { $a } } } >{ my $a = "bar"; sub bar { $a; sub { $a } } } Man, that still exists? Grumble. I ran into that a year or two ago. I would have thought Perl 5.6 would have cleaned that out. -- Jeff "japhy" Pinyan [EMAIL PROTEC

Re: Persisting Values Across Method Calls

2001-11-02 Thread Paul Johnson
On Fri, Nov 02, 2001 at 03:41:02PM -0500, Jeff 'japhy' Pinyan wrote: > On Nov 2, Paul Johnson said: > > >3. Currently, Perl exhibits some surprising behaviour in certain > >situations when a named subroutine is being used as a closure. In > >practice, Perl does not properly close named

Re: Persisting Values Across Method Calls

2001-11-02 Thread Jeff 'japhy' Pinyan
On Nov 2, Paul Johnson said: >> can be called a closure. I feel that "closure" refers more to the action, >> and less to the means -- we are creating a subroutine (named or unnamed >> makes no difference) which holds on to variables that "should" be gone. First, I have to thank you for taking t

Re: Persisting Values Across Method Calls

2001-11-02 Thread Paul Johnson
On Fri, Nov 02, 2001 at 10:51:49AM -0500, Jeff 'japhy' Pinyan wrote: > On Nov 2, Etienne Marcotte said: > > >check out http://www.crusoe.net/~jeffp/articles/pm/2000-05.html > > > >a really good document on closures... > > Before I get a barrage of "BUT THAT'S NOT A CLOSURE!" let me say this. I

Re: Persisting Values Across Method Calls

2001-11-02 Thread Jeff 'japhy' Pinyan
On Nov 2, Etienne Marcotte said: >check out http://www.crusoe.net/~jeffp/articles/pm/2000-05.html > >a really good document on closures... Before I get a barrage of "BUT THAT'S NOT A CLOSURE!" let me say this. I was told that by someone (can't remember who), and I asked merlyn (Randal) what he

Re: Persisting Values Across Method Calls

2001-11-02 Thread Etienne Marcotte
check out http://www.crusoe.net/~jeffp/articles/pm/2000-05.html a really good document on closures... Etienne Jenda Krynicky wrote: > Original suggestion (comments stripped): > > { > > my $savedData = 0; > > > > sub rememberData > > { > > $savedData = shift if @_;# upda

RE: Persisting Values Across Method Calls

2001-11-01 Thread Jenda Krynicky
Original suggestion (comments stripped): > { > my $savedData = 0; > > sub rememberData > { > $savedData = shift if @_;# update with new value if given > return $savedData; # return current value > } > } Curtis Poe <[EMAIL PROTECTED]> wrote: > Actual

RE: Persisting Values Across Method Calls

2001-10-31 Thread Curtis Poe
--- Jon Cassorla <[EMAIL PROTECTED]> wrote: > > There are many ways to do this. Here is just one example using a > closure. > > package Remember; > > # this is a closure > { > my $savedData = 0;# only accessible within this scope; side > effect is that > # it

RE: Persisting Values Across Method Calls

2001-10-31 Thread Jenda Krynicky
From: "Jon Cassorla" <[EMAIL PROTECTED]> > There are many ways to do this. Here is just one example using a > closure. > > package Remember; > > # this is a closure > { > my $savedData = 0;# only accessible within this scope; > > sub rememberData > { >

RE: Persisting Values Across Method Calls

2001-10-31 Thread Jon Cassorla
There are many ways to do this. Here is just one example using a closure. package Remember; # this is a closure { my $savedData = 0;# only accessible within this scope; side effect is that # it stays around as long as the module since the following

Re: Persisting Values Across Method Calls

2001-10-30 Thread Martin Pfeffer
you can create a object or use clouses. hope it helps Martin Rex Arul wrote: > Friends, > > How can I persist values across method calls, without using Global > Variables? IS there kind of "static" variables and if so can any of you > provide a simple code example to prove the point? > > Thank