[doc,library] Document macro system extensions.

As indicated in the text, the bulk of this text is from the
D-expressions paper.
Merge pull request #733 from waywardmonkeys/macro-extensions-docs

[doc,library] Document macro system extensions.