BRAINSTORM: return type of 'exception'
Russell Lewis
webmaster at villagersonline.com
Wed Jan 14 09:26:45 PST 2009
dsimcha wrote:
> I like the back-end compiler optimization part of this for void return types.
> However, I don't like the idea of making the programmer responsible for checking
> the error code. The nice thing about exceptions is that if you don't handle an
> exception because you believe that it can't happen in your case, then you've
> basically got an assert, and if you were wrong and it CAN happen, you'll know
> about it fast. They're also nice when you're writing a quick and dirty prototype,
> because the default behavior given bad input (such as a file that doesn't exist)
> is to fail in a reasonable way. Realistically, in a throwaway prototype I would
> never bother to check error codes, and this would probably lead to some
> frustrating "bugs" that were really caused by bad input.
I think you're missing the point of what I'm saying. What I'm
suggesting is that when you call a function with return type
"exception," the compiler would automatically check the return code for
you, and auto-throw the exception if one is returned. It's the syntax
of exceptions, with the execution speed of return codes.
More information about the Digitalmars-d
mailing list