On Dec 22, 2007 3:48 AM, John Cowan <[EMAIL PROTECTED]> wrote: > > In the language I"m implementing, catching is done not based on the > class of the thrown object but on its identity. That is, in the > general case, the throw will have to wrap the object in a descendant > of RuntimeException (which I call CatchPoint), and then each catcher > routine will begin with a line like "if (e.object != object_we_want) > throw e;" in order to rethrow the exception if the object is not > identical. > > Often, but not always, the object is a constant and its identity is > known at compile time. Is it worthwhile creating unique subclasses of > CatchPoint, one for each such manifest thrown object, so that the > above test can be omitted?
I think you should see quite a performance improvement if you do this. So, as long as you aren't generating very large numbers of these specialised classes, I think I'd do it. On a related topic, John Rose has written about efficient use of Exceptions (http://blogs.sun.com/jrose/entry/longjumps_considered_inexpensive). This may not be relevant to what you are doing here but it's useful stuff to know. John Wilson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en -~----------~----~----~----~------~----~------~--~---
