Computing

Macro

  • For our discussion, 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 M

Let us define a Macro called M with a parameter Y as follows:
M(Y) = “I take refuge in the ” + Y
Then, the prayer can be written as
M(Buddha)
M(Dhamma)
M(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) + M(Y)

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s