From 46fe5a33d9773eb6230f7bf1d1ddef8fd0fa18cf Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 27 Jul 2019 17:22:06 +0100 Subject: [PATCH] doc/concepts.tex: Explicitly define `instances' clearly. --- doc/concepts.tex | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/doc/concepts.tex b/doc/concepts.tex index d9239d0..58f781a 100644 --- a/doc/concepts.tex +++ b/doc/concepts.tex @@ -63,22 +63,33 @@ having to implement additional syntax. For the most part, Sod takes a fairly traditional view of what it means to be an object system. -An \emph{object} maintains \emph{state} and exhibits \emph{behaviour}. An -object's state is maintained in named \emph{slots}, each of which can store a -C value of an appropriate (scalar or aggregate) type. An object's behaviour -is stimulated by sending it \emph{messages}. A message has a name, and may -carry a number of arguments, which are C values; sending a message may result -in the state of receiving object (or other objects) being changed, and a C -value being returned to the sender. - -Every object is a (direct) instance of some \emph{class}. The class -determines which slots its instances have, which messages its instances can -be sent, and which methods are invoked when those messages are received. The -Sod translator's main job is to read class definitions and convert them into -appropriate C declarations, tables, and functions. An object cannot +An \emph{object} maintains \emph{state} and exhibits \emph{behaviour}. +(Here, we're using the term `object' in the usual sense of `object-oriented +programming', rather than that of the ISO~C standard. Once we have defined +an `instance' below, we shall generally prefer that term, so as to prevent +further confusion between these two uses of the word.) + +An object's state is maintained in named \emph{slots}, each of which can +store a C value of an appropriate (scalar or aggregate) type. An object's +behaviour is stimulated by sending it \emph{messages}. A message has a name, +and may carry a number of arguments, which are C values; sending a message +may result in the state of receiving object (or other objects) being changed, +and a C value being returned to the sender. + +Every object is a \emph{direct instance} of exactly one \emph{class}. The +class determines which slots its instances have, which messages its instances +can be sent, and which methods are invoked when those messages are received. +The Sod translator's main job is to read class definitions and convert them +into appropriate C declarations, tables, and functions. An object cannot (usually) change its direct class, and the direct class of an object is not affected by, for example, the static type of a pointer to it. +If an object~$x$ is a direct instance of some class~$C$, then we say that $C$ +is \emph{the class of}~$x$. Note that the class of an object is a property +of the object's value at runtime, and not of C's compile-time type system. +We shall be careful in distinguishing C's compile-time notion of \emph{type} +from Sod's run-time notion of \emph{class}. + \subsection{Superclasses and inheritance} \label{sec:concepts.classes.inherit} @@ -120,7 +131,7 @@ class then the only superclass of $C$ is $C$ itself, and $C$ has no proper superclasses. If an object is a direct instance of class~$C$ then the object is also an -(indirect) instance of every superclass of $C$. +(indirect) \emph{instance} of every superclass of $C$. If $C$ has a proper superclass $B$, then $B$ must not have $C$ as a direct superclass. In different terms, if we construct a directed graph, whose -- 2.11.0