diff options
Diffstat (limited to 'cppawk-narg.1')
-rw-r--r-- | cppawk-narg.1 | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cppawk-narg.1 b/cppawk-narg.1 index 3c1d8a3..bd6c60e 100644 --- a/cppawk-narg.1 +++ b/cppawk-narg.1 @@ -12,6 +12,7 @@ #define splice(\fIargs\fP) #define varexpand(\fIfirst_mac\fP, \fIrest_mac\fP, ...) #define variexpand(\fIfirst_mac\fP, \fIrest_mac\fP, ...) + #define variaexpand(\fIfirst_mac\fP, \fIrest_mac\fP, \fIarg\fP, ...) #define revarg(...) .ft R @@ -390,6 +391,41 @@ it with .B __LINE__ and a prefix to generate unique variables. +.IP \fBvariaexpand\fB +One more macro in the +.B varexpand +family is +.BR variaexpand . + +Like +.BR variexpand , +.B variaexpand +also passes the argument number to its child clauses. +In addition to the argument number, it passes one more argument: +a fixed argument specified in the +.B variexpand +invocation. + +For instance, suppose we wish to have a macro with the following properties: + +.ft B + series(\fIm\fP, \fIa\fP) \fI->\fP \fIm\fP(\fIa1\fP) + series(\fIm\fP, \fIa\fP, \fIb\fP) \fI->\fP \fIm\fP(\fIa1\fP) + \fIm\fP(\fIb2\fP) + series(\fIm\fP, \fIa\fP, \fIb\fP, \fIc\fP) \fI->\fP \fIm\fP(\fIa1\fP) + \fIm\fP(\fIb2\fP) + \fIm\fP(\fIc3\fP) +.ft R + +In our expansion, we want the argument numbers to be put into correspondence +with the arguments, and the argument +.B x +to be distributed into the terms: + +.ft B + #define series_first(\fIx\fP, \fIi\fP, \fIa\fP) \fIa\fP(\fIx\fP ## \fIi\fP) + #define series_next(\fIprev\fP, \fIx\fP, \fIi\fP, \fIa\fP) \fIprev\fP + \fIa\fP(\fIx\fP ## \fIi\fP) + #define series(\fIa\fP, ...) variaexpand(\fIseries_first\fP, \fIseries_next\fP, \e + \fIa\fP, __VA_ARGS__) +.ft R + .SH BUGS As noted in the DESCRIPTION, the .BR narg , |