0% found this document useful (0 votes)
12 views1 page

Keyword Parameters in Macro Calls

The document discusses how keyword parameters in macros allow for flexibility in parameter order and provide defaults. It shows an example of a PUTC macro expanding differently depending on the order of the CHAR and DEV parameters, but producing the same result either way since they are keyword parameters. It also demonstrates how a keyword parameter can have a default value specified in the macro prototype.

Uploaded by

Mohamed Med
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Keyword Parameters in Macro Calls

The document discusses how keyword parameters in macros allow for flexibility in parameter order and provide defaults. It shows an example of a PUTC macro expanding differently depending on the order of the CHAR and DEV parameters, but producing the same result either way since they are keyword parameters. It also demonstrates how a keyword parameter can have a default value specified in the macro prototype.

Uploaded by

Mohamed Med
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

If the next call is

LOOP PUTC CHAR=MSG, DEV==X'05'

then the expansion is

.LOOP PUTC CHAR=MSG, DEV==X'05'


STA $ABSAVE
LDCH MSG
J $ABLOOP
$ABSAVE RESW 1
$ABLOOP TD =X'05'
JEQ $ABLOOP
WD =X'05'
LDA $ABSAVE

The same expansion would have resulted if the call had been

LOOP PUTC DEV==X'05', CHAR=MSG

In other words, because the parameters are "named" by the keywords,


the order in which they are given does not matter. Key word
parameters are sometimes used in combination with positional
parameters to provide a default. For example, if the PUTC
prototype statement was

&INIT PUTC &CHAR, &DEV==X'04'

then the &CHAR parameter is specified by position and the &DEV


parameter is a keyword parameter with a default. In this case the
following calls are all equivalent:

PUTC DEV==X'04', =C'X'


PUTC =C'X'
PUTC =C'X', DEV==X'04'

It may be argued that using keyword parameter lists burdens the


programmer with having to remember names, but it can be very
convenient for providing default values, and is particularly useful if
there are multiple parameters needed in the macro.

You might also like