  We establish a connection between linear codes and hyperplane arrangements
using the Thomas decomposition of polynomial systems and the resulting counting
polynomial. This yields both a generalization and a refinement of the weight
enumerator of a linear code. In particular, one can deal with infinitely many
finite fields simultaneously by defining a weight enumerator for codes over
infinite fields.
