Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Note: If you're unfamiliar with state machines, this article should give you the necessary background. Also, a variant of this question was cross-posted to the module authors list.

I've been doing a lot of work with FSA::Rules for my job. I've added GraphViz support to generate state machine graphs on the fly.

To do this, here's how a state is defined (see the module for a full explanation):

installed => { do => sub { shift->result($self->_is_installed) }, rules => [ fail => { "Postgres not\ninstalled" => sub {! shift->result } + }, version => { "Postgres\ninstalled" => sub { shift->result } }, ], },

Each rule now takes an optional hash reference. If supplied, the key is the "label" that appears on the line leading from state to state (take a look at the first state on the linked graph and notice the names.)

If you prefer, you can also specify the rules the old way:

rules => [ fail => sub { ! shift->result }, version => sub { shift->result } ],

The only difference is that there is no label if a graph is generated. In other words, for rules you can use a subref or a hashref. Does that sound confusing? I think it is.

Can anyone suggest a cleaner syntax for the rule labels? Having state machine graphs auto-generated is really cool, but I don't know if it's worth the expense of making things too confusing to use. Because we're struggling with the syntax, we have not yet uploaded the version with GraphViz support.

As a side note, if you would prefer a completely different syntax for the module, we're open to anything that will make it easier to use, even though it's already pretty easy.

Cheers,
Ovid

New address of my CGI Course.


In reply to Interface design question: graphing state machines. by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-25 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found