X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/e4ea29d8e1853f8ae36ee0e65b9f5913303042d2..d7451ac3b671b96443cfc0ffb4842f03bcd1cdfe:/doc/concepts.tex diff --git a/doc/concepts.tex b/doc/concepts.tex index 64f6320..f7283e4 100644 --- a/doc/concepts.tex +++ b/doc/concepts.tex @@ -214,13 +214,13 @@ qualified by the defining class's nickname. \subsubsection{Slot initializers} As well as defining slot names and types, a class can also associate an \emph{initial value} with each slot defined by itself or one of its -subclasses. A class $C$ provides an \emph{initialization function} (see +subclasses. A class $C$ provides an \emph{initialization message} (see \xref{sec:concepts.lifecycle.birth}, and \xref{sec:structures.root.sodclass}) -which sets the slots of a \emph{direct} instance of the class to the correct -initial values. If several of $C$'s superclasses define initializers for the -same slot then the initializer from the most specific such class is used. If -none of $C$'s superclasses define an initializer for some slot then that slot -will be left uninitialized. +whose methods set the slots of a \emph{direct} instance of the class to the +correct initial values. If several of $C$'s superclasses define initializers +for the same slot then the initializer from the most specific such class is +used. If none of $C$'s superclasses define an initializer for some slot then +that slot will be left uninitialized. The initializer for a slot with scalar type may be any C expression. The initializer for a slot with aggregate type must contain only constant @@ -840,9 +840,9 @@ allocated from the standard @|malloc| heap is done using the \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 @@ -856,7 +856,7 @@ This simple protocol can be used, for example, to implement a reference 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] \\