// alpha.h, class Top__, public
int reference_count() const {return count;} // non-virtual version
// beta.h
$data List<class A> = 0 | Cons(A a, List<A> b) {
A a(A new_a) {return a_ = new_a;}
List<A> b(List<A> new_b) {return b_ = new_b;}
bool print(ostream& os);
#ifndef APP_NO_ITER_CONS_DTOR
virtual ~Cons__(); // see below
#endif
} : {
.
.
.
};
.
.
.
#ifndef APP_NO_ITER_CONS_DTOR
// For length n lists this dtor consumes O(1) space v. O(n) that can arise
// from compiler generated recursive dtor code for member variable b_.
template <class A>
Cons__<A>::~Cons__<A>() {
List<A> next = b_;
b_ = List<A>();
List<A> curr = next;
next = List<A>();
while (curr()) {
if (curr()->reference_count() > 1) break;
next = curr.tail();
curr.tail(List<A>());
curr = next;
next = List<A>();
}
}
#endif // APP_NO_ITER_CONS_DTOR
$base Associative_List<class A, class B>;
$base Extending_List<class A>;
$data A = B(int c, Atom d, A e) | F();
...
A a = B(0, "ok", B(0, "ok", F()));
...
$match (a) {
(B(e:B(d:g, c:, ...), ...)) => {...c...g...} // internally rewritten as:
(B(_, _, B(c, g, _))) => {...c...g...}
...
}
$data A = B(int c, Atom d) | E(int f) | G(Atom h, int i);
...
A a = B(0, "ok");
...
$match (a) {
(B(x, y)) => {...}
(_) => {} // default case
(E(...)) => {} // safety case
(G(...)) => {} // safety case
}
>= < > <= in beta.h have typos.