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 a first attempt patch
> against Session.pm. If you like, I can easily whip up a similar patch for
> NFA.pm
> 
> What it does, is to push an anonymous array of parameters onto a stack
> before invoking a state, and then pop if off afterwards. There are a
> complimentary set of subroutine declarations which are pushed out via
> "import" which allow you to access the parameters at the top of the stack as
> so:
> 
> $_[OBJECT]      ->  object()
> $_[SESSION]     ->  session()
> $_[KERNEL]      ->  kernel()
> $_[HEAP]        ->  heap()
> $_[STATE]       ->  state()
> $_[SENDER]      ->  sender()
> $_[CALLER_FILE] ->  caller_file()
> $_[CALLER_LINE] ->  caller_line()
> @_[ARG0..$#_]   ->  args()
> 
> I continue to pass all the test I previously passed on Win32 after the
> application of this test.
> 
> enjoy.

[patch]

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

Will the lexical @params be clobbered by multiple sessions if we ever
get them running in separate threads?

-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to