3 ms·
I have long wondered about the syntax of exceptions - if it was: void function() { try: function_body... catch(Exception e): finally: } By lea
by rvkennedy 14y ago
I have long wondered about the syntax of exceptions - if it was:
void function()
{
try:
function_body...
catch(Exception e):
finally:
}
By leaving the function body in the same indentation as it would be without exception handling, this might help to make the code a little more readable than:
void function()
{
try
{
function_body...
}
catch(Exception e)
{
}
finally
{
}
}
- AndrewDucker 14y agoThat would be useful if you only need a try/catch at method level. If you need two try/catch chunks in a method then that wouldn't work. I do agree that having try/catch at method level would be useful in many ways - as an additional piece of syntax.
- ajitk 14y agoMy mind parsed the first code block as a mix of Python and C. IMO, the later would be more readable since it involves parsing only one rule that the eye is already used.
- udp 14y agoIt reminds me more of C, where labels and goto are often used for error handling (labels using the same `:` syntax).
- ajitk 14y agoNow that you you mention labels, I see the similarity to C. I might have been influenced by OP's reference to use indentation to make code more readable instead of using braces.