"Drieux" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Friday, Sep 12, 2003, at 18:54 US/Pacific, Todd W. wrote: > [..] > > I dont think you can call that a closure yet. You would have to be > > defining > > subroutines that refer to lexical variables outside of the subroutine > > or > > something along those lines: > > > > [EMAIL PROTECTED] trwww]$ perl > > { > > my $dog = 'spot'; > > sub dogsName { > > my $pooch = $dog; > > return("my dog is $pooch"); > > } > > } > [..] > > Mea Kulpa! What Was I Thinking? I just did the > > perldoc -q closure > > but..... hum... > > { > package Foo::Bar > use base qw/Foo/; > ... > } > > Would seem to meet the minimum requirement, since > the 'use base' there deals with the @ISA for that > package name space... >
The block is still not a closure, because @ISA must be a package global for the inhertance mechanism to work its magic. use base qw/Foo/; is semantically the same as: our(@ISA) = qw/Foo/; As a matter of fact, declaring @ISA as a lexical will effectively disable inheritance for a given module: [EMAIL PROTECTED] trwww]$ perl use warnings; use strict; use CGI; { package Foo; our(@ISA) = qw/CGI/; } # inerited class method print Foo->escapeHTML('foo&bar'), "\n"; Ctrl-D foo&bar and then: [EMAIL PROTECTED] trwww]$ perl use warnings; use strict; use CGI; { package Foo; my(@ISA) = qw/CGI/; } print Foo->escapeHTML('foo&bar'), "\n"; Ctrl-D Can't locate object method "escapeHTML" via package "Foo" at - line 10. Beacuse of @ISA being lexically declared, it can't inherit from other modules. And remember, for a logical scope to be called a closure, you have to be dealing with lexical values. > But I think the part that scares me is that > > my $action = { > doDaemon => sub { ..... }, > ... > }; > > would get us into the same 'space'? Not if you declare $action to have its own file or block scope. You would have to define an accessor to access $action. > > I'm not sure I really want to actually create YA_CGI_AppServer, > although, I fear that I am in dire meandering towards that sort > of 'can one create a general enough solution'.... > > Since, well, uh, one of my doodles is about passing in a > reference to an object, and such things ... Since the basic > 'shell' of a CGI script still looks like: <snip CGI parser example /> > make_header_and_send($page_type, $page); > > so that of course yearns to be in a module, rather than > as something one would cut and paste into each new CGI script... > > But looking at your diagramme, I think I can see why you > are pointing towards a YA_CGI_AppServer.... > If you have a reuseable component that dispatches other components you can call it an application server, for some definitions of an application server. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]