Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-08-17 19:27:37


on Sun Aug 17 2008, Andrey Semashev <andrey.semashev-AT-gmail.com> wrote:

> David Abrahams wrote:
>> on Sun Aug 17 2008, Andrey Semashev <andrey.semashev-AT-gmail.com> wrote:
>>
>>> State machines, as I see it, are meant to define an object behavior,
>>> IOW reduce the amount of undefined behavior. It is pointless to use
>>> them to implement undefined behavior.
>>
>> So std::vector is pointless because it exhibits undefined behavior when
>> misused?
>
> No, vector is not pointless, because its purpose is to store elements,
> not to define behavior.

Sorry, but you're making no sense to me. The defined behaviors of
vector are just as important as the defined behaviors of your FSM
library.

> I will need vector to store elements even with undefined behavior on
> invalid pointers as its input. But why would I need FSM if it doesn't
> define my object's behavior?

Well, it would define useful behaviors for valid inputs.

> Or if I am adamant on what particular input will come from the
> environment (IOW, the behavior is already defined by the environment)?

The OP's assumption only works when you have sufficient control over the
inputs.

>>>> I find the code written using the proposed library rather procedural
>>>> in nature (rather than declarative), thus the OP's comparison is very
>>>> apt from my point-of-view. The hand-rolled code actually looks
>>>> clearer and more direct to me.
>>> Please, have a look at my reply to Phil. I've attached a code snippet
>>> with a transition map. Does that look more declarative?
>>
>> Not really, to me. It's very difficult for me to see the transitions in
>> that code. Compare that with either of my player examples.
>
> Hmm... I don't see much difference, except for comments markup. Both
> code samples use transition maps, both use vectors... Is it because the
> transition map in your code is a member of the complete FSM?

Sorry, I don't know what a "transition map" is. In fact, when I google
``fsm "transition map"'' all the top hits come from your library, which
tells me it's almost certainly not a known term in the FSM domain. I'm
talking about a State Transition Table (STT)
(http://en.wikipedia.org/wiki/State_transition_table).

The STT in my code is clearly visible at
http://svn.boost.org/trac/boost/browser/trunk/libs/mpl/example/fsm/player1.cpp#L226

Where's yours?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk