perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Chamas <>
Subject Re: RFC: subroutines & script recompilation
Date Tue, 11 Feb 2003 23:56:09 GMT
Theo E. Schlossnagle wrote:
> Josh Chamas wrote:
>> The problem is that when subroutines are defined in a script,
>> they create closure issues as discussed here:
>> The greater problem is that resolving these closure issues can
>> be a hair pulling event, and unless one gets into mod_perl
>> and Apache::ASP significantly, this may be overlooked.  I would
>> like Apache::ASP to be more newbie friendly.
>> The solution is whenever a subroutine definition is detected as in:
>> sub some_name {
>> }
> We use sub routines in pages as closures with _great_ success.  I don't 
> think
> the above suggested modification will effect our use at all.  We don't used
> named subroutines at all, only lambda functions (a.k.a. closures).

You are correct, the problem that I would be addressing would be
named subs, so your anonymous subs would remain unaffected.
Anyone using anonymous subs is tapping into an advanced enough
part of perl that they should understand the closure scoping issues
associated with that use, and I am not worried about the advanced users.

I read your example that you provided of turning part of the ASP
page into a sub for calling later by a called template.  I have
myself done this, and its pretty cool what you can pull off in this
way, but I tend to find XMLSubs cleaner for this kind of abstraction,
so instead of a master page object with a master template, one can:

<my:page title="...">
   ... customized page ...


sub my::page {
    my($args, $html) = @_;
    $main::Response->Include('', $args, $html);

The effect is actually very similar in that the XMLSubs functionality
actually wraps the enclosed content in an anonymous subroutine whose
output is captured and fed into the calling subroutine.

> Yes Josh, I real (thought out) testimonial is on the way.

Thanks, look forward to it.


Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.      
NodeWorks Link Checking      

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message