Macro expansion

Macro Expansion


MACRO EXPANSION :-

Q.        Explain Lexical expansion of macro with example. --- (6m)

Ans :- Algorithm for macro expansion :-

1) MEC ( Macro Expansion Counter ) :- This is used inside definition of MACRO. MEC is get incremented till MEND.

2) While performing MACRO expansion this MEC is used

3) Macro expansion will replace macro call by macro model statements and all formal parameters are replaced by actual parameters.

Lexical Expansion is having 3 types of expansion:-

  1. Position Parameter Expansion
  2. Keyword Parameter Expansion
  3. Default Parameter Expansion

a) Positional Parameter Expansion:-

Positional Parameter Expansion

(b) Keyword Parameters Expansion :-

 While calling macro keyword plays a important role. Actual value is get assigned to formal parameters based on keywords

 Keyword Parameters Expansion

C) Default Parameter Expansion :-

1) Default values are defined at time of macro definition.

2) If still parameters are passed while calling MACROS it will over write default value.

 Default Parameter Expansion

References


Last modified: Friday, 20 September 2019, 12:28 AM