Next: , Up: Top   [Contents][Index]

1 Introduction and preliminaries

1.1 For the reader

This document is not a manual for learning to work with macros. For learning macros in general the manuals of existing general macro processors such as GNU m4 are advised.

This document explains the possibilities, use and flexibility of the m0 macro processor. It will allow you to e.g. define your own macro language or to emulate an existing macro processor.

How the macros in m0 work is described in Macro processing. Patterns are an important feature to provide flexibility of macros and are explained in Patterns.

The functions available for macros are listed in Builtin functions, the instructions available for patterns are listed in Programs for patterns and macros.

Emulation examples found in Emulation examples demonstrate the use of m0 to emulate existing macro processors. The m4 emulation is demonstrated in M4 emulation example, the m6 emulation in M6 emulation example and the gpm emulation in GPM emulation example.

1.2 Why another macro processor?

Several good general macro processors such as m4, ML/I or gpp exist. These macro processors all have their own syntax and have no, some or more flexibility in the macro naming and use. They all have macros defined by words or "atoms" and are hereby linked to the known syntax of programming languages.

The purpose of m0 is to have almost no restrictions on syntax and with that maximum flexibility. With this flexibility it should even be possible to emulate many of the existing macro processors.

This flexibility goes so far, that at startup only 1 macro is available to name new macros. You have to name the builtin functions and define the syntax first before a complete macro processor is available!

1.3 The m0 name?

The m4 macro processor has been inspirational for the development of m0. The much used m4 macro processor has its predecessors named m3 and m6. An extended macro processor is called m5.

For a mechanical engineer these names look like metric screw thread. Besides this, m0 has as a goal to be more flexible and have more functionality than m4. It is however also more basic, in the sense that not much is predefined. This together with the trend of zero sugar drinks seems to make the m0 name appropriate.

1.4 Performance?

Intuitively a very flexible general macro processor should be a lot slower in execution than a normal general macro processor. Flexibility normally means more and slower code.

The algorithm used in m0 for detecting macros is a bitap algorithm. This algorithm is fast and flexible at the same time. A preliminary rough estimate (on a relatively modern 64 bit computer) is that m0 with m4 emulation is twice as fast as m4 processing a big file without macros. When processing a big file with macros, m0 has a similar or a little bit better performance as m4.


Next: , Up: Top   [Contents][Index]