Path: utzoo!mnetor!uunet!lll-winken!ubvax!vsi1!steve From: steve@vsi1.UUCP (Steve Maurer) Newsgroups: comp.lang.c++ Subject: Re: Proposal for Exceptions for C++ Message-ID: <481@vsi1.UUCP> Date: 7 Apr 88 19:22:30 GMT References: <8180006@eecs.nwu.edu> <8180011@eecs.nwu.edu> Reply-To: steve@vsi1.UUCP (Steve Maurer) Organization: Vicom Systems Inc. San Jose, Cal. Lines: 44 > This is in reply to Steve Maurer's suggesting on making >exceptions look like functions. > >There are several problems > 1) It does not allow more than one exceptions handler to be > defined for a given exception. (if a given exception is > declaired more than once, which one should it choose?) Presumably, this would fail to compile. If you wanted two behaviors out of your exception handler, you would have to use an 'if' statement. > 3) Often you need access to variables that are in the scope > of functions above you in the call stack to handle the > error properly. How can you do this? The C++ compiler (translator) would look to upper scopes for the variable name you requested. If found, it would record the procedure name, variable offset, and record this as arguments to a run-time routine that would return the variable's value. Of course this would work for automatic variables only. > 2) MOST times, when an exception is raised, you want to > return to the scope of a functions somewhere above you > on the stack, how do you do this? (longjumps won't work > since they do not call destructors properly) Even though the original article didn't have a keyword to do this, it should have been added. As for implementation, though this is difficult, it could be done. Basically, the C++ translator would have to generate a call to one of 2 runtime functions, which either searched for a named procedure, or simply returned up one or more levels. Both would have to call destructors during run time. Of course, this *still* doesn't give us everything we want, but I have been laboring under the assumption that most people want a construct that can be translated into C ( by one of the popular translators out there ), and I don't think that you can get everything you want and still do this. Steve Maurer p.s. I don't think anything we discuss here, ever *really* has a chance of being adopted, so I'm not sure why I bother.