  We consider topological dynamical systems over $\ZZ$ and, more generally,
locally compact, $\sigma$-compact abelian groups. We relate spectral theory and
diffraction theory. We first use a a recently developed general framework of
diffraction theory to associate an autocorrelation and a diffraction measure to
any $L^2$-function over such a dynamical system. This diffraction measure is
shown to be the spectral measure of the function. If the group has a countable
basis of the topology one can also exhibit the underlying autocorrelation by
sampling along the orbits. Building on these considerations we then show how
the spectral theory of dynamical systems can be reformulated via diffraction
theory of function dynamical systems. In particular, we show that the
diffraction measures of suitable factors provide a complete spectral invariant.
