void myFunction(){
try {
....
} catch (e) {
....
}finally{
....
}
}
void myFunction(){
....
} catch(e){
....
} finally{
....
}
+1 Nice!
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Should this only apply to "actions" (void functions)?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
When I see a specific feature like this, I try to see if it generalizes. Whether it does or not tend to be enlightening :)What if *any* block could have a catch/finally.
It sounds more general ... but it turns out, all that all it does is to remove the "try" from a try/catch/finally statement. It may be slightly shorter, but lacks the leading hint that something is wrapping the following block (all special blocks have leading syntax, "for", "while", "do", "try", "catch", "finally").
A function body isn't *exactly* a block statement, but it's close enough that if we remove "try" and make "catch/finally" a possible suffix of a block statement, it could generalize to function bodies.
So what would we lose?One thing is that the entirety of a function's body is no longer inside an outer block. That means parser complications - the "catch(e)" after a method must not be seen as a new function declaration. Since "catch" is a reserved word, that's probably not a problem.
foo() {...} on Bar {...}
It will be slightly harder to read for people trained to find the matching "}" and assume the function ends there (and ditto tools).What is the variable scope of those extra blocks? It would be reasonable that they are in scope of the function parameters. So far a "(var x) { stmts; }" has only had the scope of "x" extend to the following block. It's not a big problem to have it also extend to more blocks, but it is a slight idiosyncrasy that might trip people up.So, all in all, it adds a bunch of small differences from other languages and other parts of Dart in order to save "{ try" and "}" (and some whitespace).I'm not sure it's actually worth it (even if I personally think "try" is ugly and annoying). If anything, I'd remove the need for "try" inside the function, and still require you to wrap it in an outer "{" and "}" body delimiter.
I have to say it's a very rare habit to catch, augment and rethrow. :(
AngularDart doesn't do that really, and neither does our code usually. I wish it was easier or more prominent, since it would help the general debugging user story a lot :) especially, since stacktraces don't provide parameter information or similar in dart.
Cheers,
Andreas