On 09/21/2016 08:41 PM, Samael Wang wrote:
> The NS_ASSERTION document  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:
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. :)
dev-platform mailing list