View Single Post
  #2 (permalink)  
Old 02-26-2003
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 907
Re: Classes vs. Exceptions

Quote:
Originally posted by andreynech
Hi,

Taking in account the idea of making Slice more simple as CORBA IDL by removing unnecessary and redundant featrues I would like to ask about the motivations to introduce Exceptions as a separate entity. Would not it be possible to allow throwing any structures or classes? I understand that some languages (like Java) expose additional requirements to the type to make it possible to throw it (Throwable) but maybe Slice compiler could be smart enough to generate corresponding code if necessary? I am just curious and would be glad if somebody could comment on this topic.

Thank you,
Andrey.
Yes, we considered doing this at length. In fact, I was one of the major proponents of that. In the end we decided against it. The reason is that not all languages permit you to throw arbitrary types, such as Python and Java. Yes, we could have packed non-exception types into a language-native exception type for such languages, but then the simplicity is lost again at the language level.

We went through similar arguments with classes and structs: why have inheritance on classes but not on structs? The reasoning here was that plain structs are more efficient and can be marshaled with less overhead and mapped to a language-native plain struct, whereas, for classes, we have more overhead due to the need to deal with derivation. In the end, retaining plain structs as a separate type was seen as the right compromise.

Cheers,

Michi.
Reply With Quote