Garrett Goebel wrote:
> Garrett Goebel wrote:
> > Rocco Caputo wrote:
> > > Sent: Tuesday, November 12, 2002 10:40 AM
> > > On Mon, Nov 11, 2002 at 06:00:52PM -0600, Garrett Goebel wrote:
> > > > I noticed at:
> > > > http://poe.perl.org/?POE_RFCs/Lexical_state_parameters
> > > >
> > > > That there was a desire to: "Turn @_[KERNEL, HEAP, etc.]
> > > > into regular variables, somehow"
> > > >
> > > > Attached and also inlined at the bottom, you'll find
> > [...]
> > >
> > > I like the simplicity of this syntax. Rather than patching
> > > Session.pm, I recommend subclassing it in the same vein as
> > > http://poe.perl.org/?POE_RFCs/Named_state_parameters
> >
> > Okay, I'll take a look at doing this...
>
> If I'm going to go so far as to subclass it... I think I'll
> go a little father and attempt to remove all the special
> parameters from being passed during state invokation.
Okay... attached you will find POE::Session::SubVar (for lack of a better name). There's a script called demo.pl which should be self-explanatory. And from the scanty documentation, it'll allow you to do things like:
use POE::Kernel;
use POE::Session::SubVar;
POE::Session::SubVar->create(
inline_states => {
_start => sub {
warn "\@_: @_";
kernel->yield('count' => 1);
},
count => sub {
my ($count) = @_;
print "counted to $count\n";
kernel->yield(count => ++$count) if $count < 10;
},
_stop => sub { warn "done" },
},
args => [qw(foo bar baz)],
);
$poe_kernel->run();
exit 0;
and
POE::Session->new(
inline_state => sub {
my (@args) = @_;
heap->{args} = \@args;
kernel->yield('object_state');
},
$object => ['object_state'],
);
sub object_state {
my ($self, @args) = @_;
...
}
Rocco, perhaps if you're agreeable, you could put it (or something similar to it) out at http://poe.perl.org/poedown and update the info at http://poe.perl.org/?POE_RFCs/Lexical_state_parameters to point to it?
Garrett
--
Garrett Goebel
IS Development Specialist
ScriptPro Direct: 913.403.5261
5828 Reeds Road Main: 913.384.1008
Mission, KS 66202 Fax: 913.384.2180
www.scriptpro.com [EMAIL PROTECTED]
SubVar.zip
Description: Binary data