Metadata

The Wikipedia entry on metadata[17] begins by saying that metadata is “data about data.” That is true but not usably specific. In Clojure, metadata is data that is orthogonal to the logical value of an object. For example, a person’s first and last names are plain old data. The fact that a person object can be serialized to XML has nothing to do with the person and is therefore metadata. Likewise, the fact that a person object is dirty and needs to be flushed to the database is metadata.

The Clojure language itself uses metadata in several places. For example, vars have a metadata map containing documentation, type information, and source information. Here is the metadata for the str var:

 (meta #​'str​)
 {:ns #object[clojure.lang.Namespace ...

Get Programming Clojure, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.