...

/

Behavioral Attributes: nothrow and @nogc

Behavioral Attributes: nothrow and @nogc

Explore the nothrow and @nogc behavioral attributes of functions.

We'll cover the following...

nothrow functions

We discussed the exception mechanism in the exceptions chapter.

It would be good practice for functions to document the types of exceptions that they might throw under specific error conditions. However, as a general rule, callers should assume that any function can throw any exception.

Sometimes it is more important to know that a function does not emit any exception at all. For example, some algorithms can take advantage of the fact that certain steps cannot be interrupted by an exception. nothrow guarantees that a function does not emit any exception:

 ...