Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Motion 8 implementation with global flags and/or flagspace



Nate,
  I completely agree

Nate Hayes schrieb:
Although Motion 8 does not explicitly require global flags, such an
implementation is entirely compatible with Motion 8. Here is a sketch of a
concrete implementation:

class Interval {
    public:
double inf;
double sup;
};

template< int N >
class IntervalVector {
    public:
Interval inv[N];
};

class Decorated {
    public:
static Decoration dec;
};

class DecoratedInterval :
    public Decorated,
    public Interval {
};

template< int N >
class DecoratedIntervalVector :
    public Decorated,
    public IntervalVector< N > {
};

DecoratedInterval op(
    DecoratedInterval a, DecoratedInterval b ) {
    ...
    if ( ... ) dec.setErrorFlag();
    ...
}

DecoratedIntervalVector<N> op(
    DecoratedIntervalVector<N> a, DecoratedIntervalVector<N> b ) {
    DecoratedIntervalVector<N> tmp;
    for ( i = 0..N-1 ) tmp[i] = op(a[i],b[i]);
    return tmp;
}

bool isValid( DecoratedIntervalVector< N > e ) {
    return e.dec.isValid;
}

void main() {

    DecoratedIntervalVector< 100 > a;
    DecoratedIntervalVector< 100 > b;
    DecoratedIntervalVector< 100 > c;
    c = op(a,b);

    if ( !isValid( c ) ) {
        // handle error here
    }
}


If the Decoration class is instead changed to something like:

class Decorated {
    public:
static std::stack< Decoration > dec;
};

then the implementation has the necessary infrastructure to provide a
flagspace model.

So global flags and flagspace are both concrete implementations of the
abstract decorated interval in Motion 8.


and vice versa as your piece of code shows you can simulate the flagspace model with decorated intervals

These two implementations are nice and simple; for certain kinds of
applications and computing environments (such as John's example) they
probably will perform very well, too.

There are also some criticisms to be made of these models, depending on many
factors. For example, all the decorations are global state (even the
flagspace model is global state, since each local flagspace is managed by a
global stack). Users must be aware of this, since calling isValid( yy ) only
returns the correct result if the global state currently holds the
decoration for yy. It is reminiscent of stack-based state-machine APIs like OpenGL, where there is a very tight coupling between the users code and the state of the machine.

The point of mentioning the criticisms is not to dismiss global flags or
flagspace altogether. Rather, the point is that 1788 should not *require*
them for all implementations, since for different applications, libraries,
languages and/or hardware entirely different implementations are likely to
be more appropriate.

Nate Hayes

P.S. Note that distinguishing between Interval and DecoratedInterval allows forgetful operations on bare intervals to avoid modifying the global state.

As I said I agree

Juergen
--
=======
      o          Prof. Dr. J. Wolff v. Gudenberg,  Informatik 2
     / \         Univ. Wuerzburg,  Am Hubland,   D-97074 Wuerzburg
 info2 o        Tel.: +49 931 / 31-86602  Fax: +49 931 / 888-6603
   / \  Uni             e-mail: wolff@xxxxxxxxxxxxxxxxxxxxxxxxxxx
  o   o Wuerzburg         http://www2.informatik.uni-wuerzburg.de/