Details of initialization are necessarily class-specific, but typically it
involves setting the instance's slots to appropriate values, and possibly
-linking it into some larger data structure to keep track of it.
+linking it into some larger data structure to keep track of it. It is
+possible for initialization methods to attempt to allocate resources, but
+this must be done carefully: there is currently no way to report an error
+from object initialization, so the object must be marked as incompletely
+initialized, and left in a state where it will be safe to tear down later.
Initialization is performed by sending the imprinted instance an @|init|
message, defined by the @|SodObject| class. This message uses a nonstandard
\descref{sod_destroy}[function]{fun}.
\subsubsection{Teardown}
-Details of initialization are necessarily class-specific, but typically it
-involves setting the instance's slots to appropriate values, and possibly
-linking it into some larger data structure to keep track of it.
+Details of teardown are necessarily class-specific, but typically it
+involves releasing resources held by the instance, and disentangling it from
+any data structures it might be linked into.
Teardown is performed by sending the instance the @|teardown| message,
defined by the @|SodObject| class. The message returns an integer, used as a
counting system, as follows.
\begin{prog}
[nick = ref] \\
- class ReferenceCountedObject \{ \\ \ind
+ class ReferenceCountedObject: SodObject \{ \\ \ind
unsigned nref = 1; \\-
void inc() \{ me@->ref.nref++; \} \\-
[role = around] \\