On 09/21/2016 08:41 PM, Samael Wang wrote:
> The NS_ASSERTION document [1] says "Don't use NS_ASSERTION", which could be a 
> bit confusing that now some of the similar named macros may be deprecated but 
> some are new and encouraged.

I think that document's advice is too severe.

roc made a compelling case for *preferring* non-fatal assertions (i.e.
NS_ASSERTION) in many scenarios, particularly when failure is not
catastrophic.  See his blog post here for more details:
 http://robert.ocallahan.org/2011/12/case-for-non-fatal-assertions.html

I found (and still find) his argument there quite compelling.  I think
it's important that debug builds are able to proceed past (inevitable)
unexpected-but-not-horrible conditions -- while at the same time,
perhaps shouting about those unexpected conditions noisily so that
people can report them if they care to do so (and so that test suites fail).

Personally, I use *both* MOZ_ASSERT and NS_ASSERTION, in different
scenarios, depending on how catastrophic it would be if the asserted
condition doesn't hold, and depending on how sure I am that the
condition does-currently & must-always-in-the-future hold true.

> Could we possibly have a section in the coding guideline explaining all these 
> NS_ASSERTION / MOZ_ASSERT / NS_ENSURE_* / NS_WARN_IF and other related 
> macros, and point (or add a link on) these macros' MDN reference pages to the 
> guideline so new contributors can have an overview of when to / not-to use 
> these macros?

That is a great idea!  I would support the creation of such a page. :)

~Daniel
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to