perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Chamas <j...@chamas.com>
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:
>>
>>   http://www.apache-asp.org/style.html#Do%20not%20definc430b103
>>
>> 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 ...
</my:page>

with

sub my::page {
    my($args, $html) = @_;
    $main::Response->Include('master_page.inc', $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.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Mime
View raw message