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

Welcome to IWETHEY!

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)

Not a wholesome trottin' race, no!
58 ms