|
|
|
|||||
|
Classes vs. Exceptions
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. |
|
||||||
|
I'm afraid it's more languages than only Java.
For Java, we would basically have to make every class throwable, because every class might potentially be an exception. For other languages, it would be even worse. For example, exceptions in Python are separate from the normal type system. In addition, I believe that a separate exception type also provides more clarity to Slice code. |
|
|||||
|
Marc and Michi,
Quote:
Quote:
What do you mean? I can throw any object as an exception in Python. Including built-in types like strings and integers.BTW I agree with your decision with regards to keeping exceptions a separate type in Slice. Here's some examples: Code:
#!/usr/bin/env python
# Define an exception class.
# Note that there's nothing special about it!
class SomeException:
def __init__(self, msg, severity):
"""Create an instance of the exception class"""
self.msg = msg
self.severity = severity
def __str__(self):
"""Convert the exception to a string"""
return ("SomeException (msg:%s, severity: %d)" %
(self.msg, self.severity))
# Throw an instance of the new class
try:
raise SomeException('Bad craziness', 42)
except SomeException, e:
print 'Caught:', e
|
|
||||||
|
We worked on a project called "Pyce" (Ice for Python) some time ago. At this time, Ice still allowed "everything to be an exception", and we had a lot of trouble implementing this model with the Python/C API.
However, it is quite possible that we simply did something wrong. We are no Python gurus. In any case, I can't remember the details, it's too long ago, and Pyce is now on hold. If someone with more Python experience wants to pick up Pyce, we would of course be more than happy to help whereever we can Ice for Python would definitely be very cool. |
|
|||||
|
Quote:
Implementing simple functions is fine ... but the rules for implementing new classes in C only existed in skeleton form in the documentation last time I looked. One of my plans is to figure it out and update the documentation. One of these days ... Quote:
Quote:
I'm supporting two scripting ORBs in my own time at the moment, and that is too much I'm afraid. And I'm supposed to be having a break! So, much as I'd like to, I can't right now. |
|
|||||
|
Quote:
-Andrew
__________________
You are in a maze of twisty little passages, all different. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C# exceptions | wrobbie | Help Center | 7 | 09-25-2005 07:03 PM |
| Catching Exceptions | chuatecksiong | Help Center | 3 | 04-06-2005 01:02 PM |
| Exceptions cannot be unmarshalled on client | robert | Bug Reports | 4 | 10-17-2004 11:46 PM |
| Exceptions and the ice_throw function | marlowa | Help Center | 2 | 02-28-2003 07:37 AM |