On Tue, May 24, 2005 at 06:15:41PM -0500, Tim Klein wrote:
> As a result of a discussion here a few weeks ago (on March 30, in 
> case you want to retrieve it from the archives), I learned that the 
> 'options' parameter to POE::Session::create is not meant to be used 
> for "custom" options.  For example, the following, even though it may 
> work, is not proper:
> 
> POE::Session->create
>  (
>   inline_states => [...],
>   options => { 'myname' => 'Tim' }    <--- my custom option 'myname'
>  );
> 
> Instead, the proper way to pass custom parameters at session creation 
> time is to use the 'heap' parameter or the 'args' parameter to the 
> create() command.
> 
> OK, so far so good.  But what's the proper way to do the same thing 
> when creating a POE::NFA instead of a POE::Session?  The 
> POE::NFA::spawn command doesn't have a 'heap' (or 'runstate') 
> parameter or an 'args' parameter.  The perldoc says "The spawn() 
> method currently only accepts inline_states and options."  So do I 
> have to use 'options' after all?

POE::NFA is not well documented.  It seems to be the strange cousin of
POE::Session that people rarely talk about, so time is focused
elsewhere.

The NFA session doesn't have a single _start event, so there's nowhere
for constructor parameters to go.  And while it may have many states,
there's no initial state specified in spawn().

So the key to starting a state is partially documented in the
SYNOPSIS:

 # Spawn an NFA and enter its initial state.
 POE::NFA->spawn(
   inline_states => \%states
 )->goto_state( $start_state, $start_event );

That spawns a new POE::NFA instance, enters its initial state, and
fires off an event that notifies the session that the state has been
entered.

The next clue in this puzzle is goto_state() itself.  Its third and
subsequent parameters are passed as arguments to the $start_event in
the state being entered.

I hope that helps.

-- 
Rocco Caputo - http://poe.perl.org/

Reply via email to