Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Even C preprocessor macros count parenthesis.

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


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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: