IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Actually I'm mostly interested in what...
...Neel is tossing around as the alternatives for his implementation, so I'm just engaging in a little idle speculation. :-)

As far as I can tell exceptions involve two things: (1). a set of code to run when an exception occurs; and (2). a continuation point to jump to once that code is completed. I gathered from your assesment that you think these features have been reduced to a glorified goto construct (reversing the order i just gave). My point, if there was one, was that instead of being a label to which one branches to, the code to be executed can also be thought of as anonymous function which gets fired when an exception event us triggered. No comment was given on the effect in terms of continuation.

Anyhow, other than establishing whether an event is handled or whether it simply throws the exception up the continuation stack, the checked exception handling in Java doesn't give any other clues to the compiler (for static checking purposes). Might be valuable information, but it provides no information beyond the propagation.
New What my thinking on this is...
In the original Go To Considered Harmful paper, a number of still valid uses for goto were listed. Exception handling was one of those.

AFAIK, exception systems were created to provide for an "exceptional program flow" mechanism which was still structured, attempting to eliminate a problem that goto was still used for.

So it isn't that exceptions come down to a glorified goto, it is that they are good enough at subverting the structured flow of control that they can share some of the problems that goto has.

See [link|http://c2.com/cgi/wiki?AvoidExceptionsWheneverPossible|http://c2.com/cgi/wi...sWheneverPossible] for an entry point into a similar discussion.

Cheers,
Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
New Re: Actually I'm mostly interested in what...
What I'd like is for exception handlers to be lexically scoped rather than dynamically scoped. For example, consider the pseudocode:

\nfun make_foo() {\n   try {\n     lambda(){ raise Error; }\n   } catch (Error) {\n     print("Error caught in make_foo!");\n   }\n}\n\nfun main() {\n  try\n    let foo = make_foo();\n    foo();\n  catch (Error) {\n    print("Error caught in main!");\n  }\n}\n


In a conventional exception system, running main() would result in foo() throwing an error that would be caught in main, and the message that main prints would be "Error caught in main!". This is dynamic scoping -- the exception handler chosen is the nearest enclosing handler live on the call stack. I'd like to try a lexically scoped exception system. In this version, the exception thrown in foo() would be caught by the lexically-enclosing exception handler -- that is, the one in make_foo(). So the printed message would be "Error caught in make_foo!"

As it happens, a lexical discipline offers more powerful control flow than a dynamic one (you can write call/cc with it!!), but it is also easier to analyze in a modular way. But this isn't the whole story. To make such a system really useful to the programmer, you still need a type language that can express differing sets of exceptions concisely and precisely, and that's a hard problem: the two needs are at cross-purposes. But the lack of such is what makes Java's checked exceptions mostly useless.
New Why not include the exception processing in the lambda?
Not sure I understand why the exception processing is not bundled as part of the anonymous function:
\nfun make_foo() {\n   lambda(){ \n      try { \n         raise Error; \n      } catch (Error) {\n         print("Error caught in make_foo!");\n      }\n   }\n}\n
Would the catch not then be lexically scoped within the lambda function? I guess I don't understand what you are trying to. In the current languages, the exception within make_foo would only be trapped if the error were in the creation of the lambda function - not in the invocation.

Also, I gather you still think the continuation point should be based on the point of invocation - not the point of defintion. So do you think the next statement executed after the try-catch in the main block?
\nfun main() {\n  try\n    let foo = make_foo();\n    foo();\n  catch (Error) {\n    print("Error caught in main!");\n  }\n  print("here's where i end up when all is said and done?");\n}\n
New Re: Why not include the exception processing in the lambda?
The exception isn't part of the lambda, since I was trying to come up with the shortest example that illustrated the issue I was talking about. :)


Also, I gather you still think the continuation point should be based on the point of invocation - not the point of defintion. So do you think the next statement executed after the try-catch in the main block?
\nfun main() {\n  try\n    let foo = make_foo();\n    foo();\n  catch (Error) {\n    print("Error caught in main!");\n  }\n  print("here's where i end up when all is said and done?");\n}

I'm not sure what you mean by "continuation point should be based on the point of invocation", but I do want execution to continue normally after the exception is handled (that's kind of the point of an exception, after all!). So your example should print
\nError caught in make_foo!\nhere's where i end up when all is said and done?\n

     Checked Exceptions, Good or Bad - (bluke) - (25)
         Agreed, for the most part. - (admin) - (5)
             Checked Exceptions: A Failed Experiment - (JimWeirich) - (4)
                 Re: Checked Exceptions: A Failed Experiment - (admin) - (3)
                     Re: Checked Exceptions: A Failed Experiment - (JimWeirich) - (2)
                         Note the quotes: "ought" to. - (admin) - (1)
                             Thanks - (JimWeirich)
         Bad of course - (tuberculosis)
         Hey look - I got a new sig out of that article - (tuberculosis) - (1)
             Buahahah. -NT - (admin)
         Designers should ALWAYS look for pushback - (ben_tilly) - (15)
             OT: I didn't picture you reading Cato stuff. :-) - (Another Scott) - (5)
                 I don't generally - (ben_tilly) - (4)
                     I can't offer an opinion. - (Another Scott) - (3)
                         Cato's been mucking around since the '60s at least - (Ashton) - (2)
                             Re: Cato's been mucking around since the '60s at least - (neelk) - (1)
                                 Re: Cato's been mucking around since the '60s at least - (Ashton)
             Re: Designers should ALWAYS look for pushback - (neelk) - (8)
                 How do you do "meta" flow of control? - (ben_tilly) - (7)
                     Another possible solution to exceptions... - (ChrisR) - (6)
                         Not appropriate for the situation being discussed - (ben_tilly) - (5)
                             Actually I'm mostly interested in what... - (ChrisR) - (4)
                                 What my thinking on this is... - (ben_tilly)
                                 Re: Actually I'm mostly interested in what... - (neelk) - (2)
                                     Why not include the exception processing in the lambda? - (ChrisR) - (1)
                                         Re: Why not include the exception processing in the lambda? - (neelk)

His laugh sounds like a balloon deflating into the face of a man who is throwing up and singing at the same time. It is the worst.
90 ms