マクロで実装。
その特性上、関数やサブルーチン内から外に向けたthrowは行えません。(内部で例外ブロックを使用することは可能。)
また、finallyの実装が完全ではありません。
finallyの実行はcatchの後となり、またtryやcatch内でgotoやbreak、returnなどを実行した場合にはfinallyは実行されません。
マクロで実装。
その特性上、関数やサブルーチン内から外に向けたthrowは行えません。(内部で例外ブロックを使用することは可能。)
また、finallyの実装が完全ではありません。
finallyの実行はcatchの後となり、またtryやcatch内でgotoやbreak、returnなどを実行した場合にはfinallyは実行されません。
#define global try %tException %i=0:%i=0:if'%i'#define global finally %tException if 1#define global ctype catch(%1) %tException *%o:%1=%o:if %o#define global throw(%1) %tException %p1=%1:%p2=1:goto*%p0mes "--------------------"try {mes "--try1"throw 1234567// throw "Test"} catch(e) {mes "--catch1 " + e} finally {mes "--finally1"}mes "--------------------"try {mes "--try2"// throw 1234567throw "Test"} catch(e) {mes "--catch2 " + e} finally {mes "--finally2"}mes "--------------------"try {mes "--try3"// throw 1234567// throw "Test"} catch(e) {mes "--catch3 " + e} finally {mes "--finally3"}mes "--------------------"try {mes "--try4"throw 1.234567} catch(e) {mes "--catch4 " + e}mes "--------------------"try {mes "--try5"} catch(e) {mes "--catch5 " + e}mes "--------------------"stop