Re: How much do we close over?

2005-06-12 Thread Autrijus Tang
On Mon, Jun 13, 2005 at 12:57:32AM +0200, Chip Salzenberg wrote: > On Sun, Jun 12, 2005 at 11:26:49PM +0100, Piers Cawley wrote: > > sub foo { my $x = 1; return sub { eval $^codestring } } > > say foo()("$x"); > > I'm pretty sure you meant single-quoted, and you perhaps might maybe > need

Re: How much do we close over?

2005-06-12 Thread Chip Salzenberg
On Sun, Jun 12, 2005 at 11:26:49PM +0100, Piers Cawley wrote: > sub foo { my $x = 1; return sub { eval $^codestring } } > say foo()("$x"); I'm pretty sure you meant single-quoted, and you perhaps might maybe need a dot there: sub foo { my $x = 1; return sub { eval $^codestring } }

Re: How much do we close over?

2005-06-12 Thread Brent 'Dax' Royal-Gordon
On 6/12/05, Dave Mitchell <[EMAIL PROTECTED]> wrote: > You may be using slow evals, but other fast code may not be. Should the > closure in > > sub foo { my $x = 1; return sub { 1 } } > > also capture the current instance of $x? You are basically condeming any > code that creates any closure,

Re: How much do we close over?

2005-06-12 Thread Dave Mitchell
On Sun, Jun 12, 2005 at 06:22:22PM -0500, Rod Adams wrote: > Well, you could always do something like: > >sub foo { my $x = 1; return sub {my $x := $OUTER::x; eval $^codestring} } In perl5, that would just be sub foo { my $x = 1; return sub { $x ; eval $_[0]} } -- You live and learn (a

Re: How much do we close over?

2005-06-12 Thread Dave Mitchell
On Sun, Jun 12, 2005 at 11:26:49PM +0100, Piers Cawley wrote: > Chip and I have been having a discussion. I want to write: > > sub foo { my $x = 1; return sub { eval $^codestring } } > say foo()("$x"); > > I claim that that should print 1. Chip claims it should throw a warning > about bec

Re: How much do we close over?

2005-06-12 Thread Rod Adams
Piers Cawley wrote: Chip and I have been having a discussion. I want to write: sub foo { my $x = 1; return sub { eval $^codestring } } say foo()("$x"); I claim that that should print 1. Chip claims it should throw a warning about because of timely destruction. My claim is that a closure

Re: How much do we close over?

2005-06-12 Thread Rob Kinyon
> Piers Cawley said: > in other words, some way of declaring that a subroutine wants to hang onto > every lexical it can see in its lexical stack, not matter what static analysis > may say. I'm not arguing with the idea, in general. I just want to point out that this implies that you're going to h

How much do we close over?

2005-06-12 Thread Piers Cawley
Chip and I have been having a discussion. I want to write: sub foo { my $x = 1; return sub { eval $^codestring } } say foo()("$x"); I claim that that should print 1. Chip claims it should throw a warning about because of timely destruction. My claim is that a closure should close over the

Re: caller and want

2005-06-12 Thread Gaal Yahas
On Wed, Jun 08, 2005 at 12:20:57PM -0700, Larry Wall wrote: > : I'm not sure how this selection mechanism is meant to be used. > > The skip is meant to be applied after filtration. Don't filter out > things you want to see later, in other words. Okay, caller done as r4555. Without :label for now