// Testing polymophic exception types. #include forall(T &) exception proxy {}; vtable(proxy(int)) proxy_int; vtable(proxy(char)) proxy_char; void proxy_test(void) { proxy(int) an_int = {&proxy_int}; proxy(char) a_char = {&proxy_char}; try { throw an_int; } catch (proxy(int) *) { sout | "terminate catch"; } try { throwResume a_char; } catchResume (proxy(char) *) { sout | "resume catch"; } try { throw a_char; } catch (proxy(int) *) { sout | "caught proxy(int)"; } catch (proxy(char) *) { sout | "caught proxy(char)"; } } forall(T) exception cell { T data; }; vtable(cell(int)) int_cell; vtable(cell(char)) char_cell; vtable(cell(bool)) bool_cell; void cell_test(void) { try { cell(int) except = {&int_cell, -7}; throw except; } catch (cell(int) * error) { sout | error->data; } try { cell(bool) ball = {&bool_cell, false}; throwResume ball; sout | ball.data; } catchResume (cell(bool) * error) { sout | error->data; error->data = true; } } int main(int argc, char * argv[]) { proxy_test(); sout | nl; cell_test(); }