ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: How much do we close over?
by Brent 'Dax' Royal-Gordon other posts by this author
Jun 12 2005 8:38PM messages near this date
Re: How much do we close over? | Re: How much do we close over?
On 6/12/05, Dave Mitchell <davem@[...].com>  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, however simple, to basically hang on to
>  just about any data that has ever existed, in the vague hope that maybe,
>  just maybe, some day some code may use an eval and make use of that data.

A simple analysis of the parse tree should show that sub { 1 } isn't
going to access $x.  I personally don't see what's wrong with marking
certain constructs (eval, symbolic dereference, stash access, etc.) as
"dirty" and forcing a closure to close over everything if one is
present.  This is optimizer stuff, really, in the same class of
problems as optimizing Parrot's continuation-based sub calls into
bsr/ret where possible.

Hmm...maybe the answer is that most destruction isn't guaranteed to be
timely, and any object which *is* guaranteed to have timely
destruction is illegal to close over unless the programmer marks it as
okay.  Or maybe that's only with an appropriate stricture...

--
Brent 'Dax' Royal-Gordon <brent@[...].com> 
Perl and Parrot hacker
Thread:
Dave Mitchell
Brent 'Dax' Royal-Gordon

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved