top | item 17735997

(no title)

jD91mZM2 | 7 years ago

I gotta say what I really like about macros are that ( and )s are matched. If you say:

  while ($($cond:tt)*) {
You'll actually match both

  while (true) {
and

  while (5 * (2 + 3)) {
. It counts the parenthesis :D

discuss

order

kazinator|7 years ago

Even C preprocessor macros count parenthesis.

   MAC((here, have one argument), and then this second one)

dan-robertson|7 years ago

But this is a requirement of the “you must be able to parse source code including macros without having to know how to expand macros” rule. Otherwise how would you know how to parse the following:

  foo!((x))
As

  foo! ( { ( x ) } )
Or

  foo! ( { ( x } ) )
With {} representing the argument to the macro.