2014/1/7 Neil <n...@parkwaycc.co.uk> > Benoit Jacob wrote: > > I would like a random voice in favor of deprecating NS_ENSURE_* for the >> reason that hiding control flow behind macros is IMO one of the most evil >> usage patterns of macros. >> >> So you're saying that > > nsresult rv = Foo(); > NS_ENSURE_SUCCESS(rv, rv); > > is hiding the control flow of the equivalent JavaScript > > try { > Foo(); > } catch (e) { > throw e; > } > > except of course that nobody writes JavaScript like that... >
All I mean is that NS_ENSURE_SUCCESS hides a 'return' statement. #define NS_ENSURE_SUCCESS(res, ret) \ do { \ nsresult __rv = res; /* Don't evaluate |res| more than once */ \ if (NS_FAILED(__rv)) { \ NS_ENSURE_SUCCESS_BODY(res, ret) \ return ret; \ } \ } while(0) For example, if I'm scanning a function for possible early returns (say I'm debugging a bug where we're forgetting to close or delete a thing before returning), I now need to scan for NS_ENSURE_SUCCESS in addition to scanning for return. That's why hiding control flow in macros is, in my opinion, never acceptable. Benoit > > -- > Warning: May contain traces of nuts. > > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform