1: include "std"; 2: fun guarded_div(a:int, b:int when b!=0) = 3: { 4: return a/b; 5: } 6: print (guarded_div(2,4)); print "\n"; 7:
1: include "std"; 2: fun abs_div(a:int, b:int when b!=0) expect result >=0 = 3: { 4: return abs(a/b); 5: } 6: print (abs_div(2,4)); print "\n"; 7:
If a pre or post condition is not met, a C++ exception is thrown. Typically this will result in a diagnostic error being printed the thread terminated by the driver. However it is driver dependent.
At present (Felix 1.1.1) recovery is not possible, nor is it possible to catch the exception.