• entries
    359
  • comments
    237
  • views
    188610

Tangent: Exceptions

Sign in to follow this  

174 views

Spent some time last night implementing exceptions. Nothing too special here. try/throw/catch/finally as they exist in C#. Under the hood, I just use the existing exception mechanism to do the delivery, and wrap exceptions so that the runtime can distinguish between exceptions raised in the runtime and exceptions raised by the runtime.

The two main differences are that you may throw any object, not just exceptions and that the catch parameters use Tangent types. So the catch uses structural subtyping to see if an exception matches it. Not big changes, just little things to keep the feel of the language consistent.

The example test code of the day:


public static main()=>void{
try{
//throw "moo.";
//throw 42;
throw 3.14;
}catch(string speech){
Console.WriteLine(speech);
}catch(int count){
Console.WriteLine(count);
}finally{
Console.WriteLine("finally.");
}
}

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now