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

Re: Motion P1788/M0008.01_Exception_Handling



Nate Hayes wrote:

Note that if yy is a 100 element vector, it is normal in vector operations
that evaluating

    yy <= 0

requires 100 component-wise evaluations of yy. In this regard, the fact that

    isValid( yy )

requires 100 component-wise examinations of yy elements does not seem to
me poor design; it is just status-quo for vector operations. Along these lines,
I think your example breaks the syntactic model one would generally expect
from a vector library. So if clean and natural code syntax is your concern,
I think the FLAG implementation may be the wrong approach.

However, an object-oriented design might be able to salvage the model by introducing the notion of a "decorated interval vector", e.g.,

    class DecoratedIntervalVector< N > {
        public:
    Interval inv[N];
    Decoration dec;
    };

    DecoratedIntervalVector< n > yy[P];

Now the compiler has something to possibly work with to make the FLAG model more natural in its vector-like syntax.

Nate Hayes


Nate, P1788,

we have read the motion 8 carefully, but we still have some questions: In particular the way the operation is not specified clearly for us.

Are there separated operations for bare and decorated intervals or have the former be cast to the latter?

An operation of the decorated interval vector example above would read in our opinion:

DecoratedIntervalVector< n > operation (DecoratedIntervalVector< n > v1,
    DecoratedIntervalVector< n > v2) {
  DecoratedIntervalVector v;

  for (i...n) {
    DecoratedInterval temp = op(v1[i], v2[i]);
    v.dec |= temp.dec;
    v.inv[i] = temp.interval;
  }

  return v;
}


We would like to discuss our new concept of flagspaces.

Flagspaces are scopes like namespaces or blocks.
Flagspaces manage information about exceptions, either a set of flags or
decoration trits.


Flagspaces are an alternative to the decorated intervals of motion 8, all intervals are bare the decoration is kept by the flagspaces. They provide a user defined scope of decorations, hence each granularity between global flag and decorated interval can be acheived. We have regional flags, the larger the region, the better the code.

Flagspaces may be nested consistent with the usual scope nesting. There are 3 possible transfer mechanisms between nested flagspaces.

1. copy existing flags on entrance but don't deliver the new flags on exit.
2. don't copy existing flags on entrance and don't deliver the new flags on exit
3. don't copy existing flags on entrance but  deliver the new flags on exit.
The fourth case copy on entrance and exit would be the same as not opening a new flagspace.

Function evaluation is defined as if the body with replaced arguments is executed inline.

As a language extension flagspaces can effectively be implemented. But implementation in standard C++ may cost some efficiency.

The source code for the example above could look like this:


Interval {
....

    Interval op(Interval i1, Interval i2) {
        ....
        if (...)
            flagspace.setErrorFlag();

       ....
    }
}


IntervalVector {

    Interval data[];

....


    IntervalVector operator(IntervalVector v1, IntervalVector v2) {
        IntervalVector tmp;

        for (i...)
            tmp[i] = op(v1[i], v2[i]);

        return tmp;	
    }

}


....

main {

    flagspace {

         IntervalVector v1;
         IntervalVector v2;

         IntervalVector v = operator(v1, v2);

         if isErrorFlag {
            ....
        }
    }
}


comments welcome


Juergen, Stefan & Marco

--
     o           Marco Nehmeier, Lehrstuhl fuer Informatik II
    / \          Universitaet Wuerzburg, Am Hubland, D-97074 Wuerzburg
InfoII o         Tel.: +49 931 / 31 88684
  / \  Uni       E-Mail: nehmeier@xxxxxxxxxxxxxxxxxxxxxxxxxxx
 o   o Wuerzburg