On Wednesday, Feb 12, 2003, at 08:49 US/Eastern, Csongor Fagyal wrote:

Josh Chamas wrote:
The solution is whenever a subroutine definition is detected as in:

sub some_name {

}

that script will be compiled as normal, but the (re)compilation
will be forced each script invocation.  The closure issues will
go away because the subroutines will be redefined each script
request.  The downside is that there will be a performance hit
where there was none before.

Any advanced user should know not to put subs in scripts,
so I am not worried about the performance hit to people that
know what they are doing.  This in effect would create a
penalty for those that do not follow the STYLE GUIDE.
What about making this a default, and let the user configure if the "old" method is preferred or the new one? (If it is easy to do - otherwise I don't think anyone writes closures _intentionally_, so applying this patch would not hurt.)

Because this fix will be functionally transparent, I do not
think I should save it for 3.0

There is another associated fix, to recompile global.asa per
request when XMLSubs are detected there, or subs defined
in a package not their own, as in:

sub package::some_sub {

}

which can also create closure issues.  I don't believe this is
as frequent a problem for newbies though, so not as concerned
about this and can save this fix for later sometime if necessary.

Any comments?
This later one is less important IMHO.

Also, the problem is that closures themselves are somewhat hard to understand: I consider them as being the part of "advanced" perl programming. If you tell a Perl/ASP newbie not to use subs in ASP, the he will place it in an external file and "require" it. Too bad... Apache::ASP should be easy to use even for those who are not perl guru-s - Apache::ASP should be _the_ alternative for PHP. I think we all would welcome a modification like this, especially since sometimes people have to use pre-written scripts which break when unwanted closures appear.
Saying that no one uses closures intentionally is wrong. I use them extensively... intentionally... and successfully.

Josh is talking about named subs, not closures. When Josh said that they create closure issues, I believe he was referring to the lexical scoping issues surrounding using subroutines defined inside subroutines that can be very confusing to those who don't have a very firm grasp of the Perl language (and sometimes to those who do ;-)).

Proper closures (or lambda functions) aren't hard to understand at all, they are one of the most basic concepts of Lisp. They also happen to be a large part of event systems and most windowing systems. Perl OTOH is somewhat hard to understand ;-)

I agree that using named subs in an asp file should be discouraged -- if by recompiling, or by simply refusing to work. In fact, in wouldn't effect my life it Apache::ASP forbade the use of named subs in asp files (by refusing to compile them). However, I would like (actually need) to continue using anonymous closures in my code. If the functionality can be written to ignore anonymous closures, that would be best.

--
Theo Schlossnagle
Principal Consultant
OmniTI Computer Consulting, Inc. -- http://www.omniti.com/
Phone: +1 410 872 4910 x201 Fax: +1 410 872 4911
1024D/82844984/95FD 30F1 489E 4613 F22E 491A 7E88 364C 8284 4984
2047R/33131B65/71 F7 95 64 49 76 5D BA 3D 90 B9 9F BE 27 24 E7


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to