August 27, 2001
Russ Lewis wrote:
> Charles Hixson wrote:
> ...> Removing char* throws just means that we implement a char* constructor in the
> Error() class.  Your code changes from
> 
> throw "Class Rhinocerous :: Gore :: error 23 :: No kind of horn found";
>     to
> throw Error("Class Rhinocerous :: Gore :: error 23 :: No kind of horn found");
> 
> which isn't very bad, IMHO, and it simplifies the exception handling some.
> 
> OR MAYBE...if you pass a non-class type as an exception, the compiler
> automatically turns it into a call of a constructor on the Error() class?  It
> would be a syntax error if you try to throw a type that has no constructor.
> 
> 
That does everything that I wanted.  I was misunderstanding when you said "remove throwing char**".  I certainly don't see anything wrong with putting a wrapper around it.  (And it could be quite useful.)



August 28, 2001
Walter wrote:
> 
> Russell Bornschlegel wrote in message <3B89ED69.166E5344@estarcion.com>...
> >Is there a compiler reason why C++'s throw-of-any-type won't work well?
> 
> It simplifies the internal workings of the compiler and the implementation of the runtime library support if only class objects can be thrown.
> 
> I've also never seen a credible use for (or even an argument for) throwing int's or unsigned char **'s, so I doubt that will be missed.

  I just thought of something.  Could exception possibly be an interface
instead of a class?  It might be convienient of declare a useful type as
something that can also be thrown.  Otherwise you would have to define
an exception class that has the type you'd really like to throw as a
member.  That's doable, but the interface might be easier.  If we
eventually get a way to declare generic types, the wrapper class would
be less of a problem too.  Just thought I'd ask.

Dan
August 28, 2001
> I just thought of something.  Could exception possibly be an interface
> instead of a class?  It might be convienient of declare a useful type as
> something that can also be thrown.  Otherwise you would have to define
> an exception class that has the type you'd really like to throw as a
> member.  That's doable, but the interface might be easier.  If we
> eventually get a way to declare generic types, the wrapper class would
> be less of a problem too.  Just thought I'd ask.

I'm not sure I understand the point here, but I think it's mostly moot.  I guess what I'm not sure about is what you mean by a "useful type" to be thrown as an exception.  If all exceptions have to implement an interface, then they have to be classes.  I can't see how even with exception as an interface you plan to throw another type other than an object reference.

If I'm totally missing the point, I'm terribly sorry.  I'm just not sure exactly what you're trying to accomplish...

Eric

August 28, 2001
Eric Gerlach wrote:
> 
> > I just thought of something.  Could exception possibly be an interface instead of a class?  It might be convienient of declare a useful type as something that can also be thrown.  Otherwise you would have to define an exception class that has the type you'd really like to throw as a member.  That's doable, but the interface might be easier.  If we eventually get a way to declare generic types, the wrapper class would be less of a problem too.  Just thought I'd ask.
> 
> I'm not sure I understand the point here, but I think it's mostly moot.
>   I guess what I'm not sure about is what you mean by a "useful type" to
> be thrown as an exception.  If all exceptions have to implement an
> interface, then they have to be classes.  I can't see how even with
> exception as an interface you plan to throw another type other than an
> object reference.
> 
> If I'm totally missing the point, I'm terribly sorry.  I'm just not sure exactly what you're trying to accomplish...

	That's because I wasn't clear.  :-)  I'm not trying to avoid throwing
an object, I'm try to keep from inventing a new type to throw.  I can
create a class that, among other things, implements Exception.  Then
during processing, if I find that I have such an object in a bad state,
I throw it at some one to have it fixed.
	If Exception is a class, then my exception is only a class.  That's
it.  I have to create a new class for each type of exception, solely for
the purpose of throw.  I guess I have the fact that exception have to be
declared as a full class when in most cases I would be doing:

	class TooManyMoves : Exception {} // You SUCK!
	class InvalidMove  : Exception {} // no no no
	class InvalidSetup : Exception {}  // board can be setup this way

when I would almost rather say:

	Exception TooManyMoves,	 // You SUCK!
	          InvalidMove,   // no no no
	   	  InvalidSetup;  // board can be setup this way

Or worse:
	class MyException : Exception{
	    public:
		mytype problem_data;
		MyException(mytype meaningful_stuff):
			problem_data(meaningful_stuff){}
	}

when it should be enough to say:

	Exception<mytype> MyException;

I know this syntax is garbage, but I think the class declaration syntax
is always overkill for what people do with exceptions.  That why a lot
of people just use strings.  In the end you are declaring an exception
type because you want a unique symbol that might wrap a message and/or
piece of data.
	I don't know if this an annoyance to anyone else or not, but it was the
primary reason why I was slow to use exceptions instead of return codes
in my classes in C++ and Java.

Dan
1 2
Next ›   Last »