Boost logo

Boost :

Subject: Re: [boost] [msm]exit pseudo state and event
From: Takatoshi Kondo (kondo_at_[hidden])
Date: 2011-07-12 19:31:00


On Mon, 11 Jul 2011 21:31:43 +0200
"Christophe Henry" <christophe.j.henry_at_[hidden]> wrote:

> > The functor Not_ is suitable for "else".
> > But if we have much more guards, We have to use Or_ functor like this.
> > msme::Not_< msme::Or_< msme::Or_<Guard1, Guard2>, Guard3> >
> >
> > Off the top of my head, how about the functor Else_ below?
> > Else_ <Guard1, Guard2, Guard3, ... >
>
> For else, we can use the fact that msm tries guards from the bottom of the
> table to the top:
>
> // else clause
> Row< state1, ev, state2, none, none>,
> // if clause
> Row< state1, ev, state2, none, Or_<...> >
> // more if clauses
> ...

Fantastic!
This has 2 advantages and 1 disadvantage.

Advantages:
One is simple enough. The other is good performance.
It doesn't need evaluating the guard functor twice.
I was about to consider how to cache the functor's result.

Disadvantage:
As you might expect, the evaluating direction is opposite of my intuition.

Are there any reasons of this implementation?
Modifying to the opposite direction is easy?

> It's not UML-conform, but well ;-)
>
> HTH,
>
> Christophe

Regards,
Takatoshi


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