Macro

  • A Macro is a text pattern with one or more arguments (or parameters).
  • Assembly Languages and Scripts support Macros.
  • We will illustrate Macros with some prayers.

Example of a Macro

Some people take the Three Refuges as follows.

  • I take refuge in the Buddha.
  • I take refuge in the Dhamma.
  • I take refuge in the Sangha.

Macro Refuge

Let us define a Macro called M with a parameter Y as follows:
Refuge(Y) = “I take refuge in the ” + Y

Then, the prayer can be written as
Refuge(Buddha)
Refuge(Dhamma)
Refuge(Sangha)

Macro Repeat

Some repeat the Three Refuges three times.

For the first time, I take refuge in the Buddha.

For the second time, I take refuge in the Buddha.

For the third time, I take refuge in the Buddha.

Let us define a Macro Repeat with a parameter X :

Repeat(X) = “For the ” + X + ” time

Macro Pray

Finally, define a Macro Pray with two parameters X and Y as follows :

Pray(X, Y) = Repeat(X) + Refuge(Y)

Then, Pray(second, Dhamma) yields “For the second time, I take refuge in the Dhamma.”

Comments

Leave a comment