Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variadic macros #52

Open
Artoria2e5 opened this issue Mar 1, 2021 · 3 comments
Open

Variadic macros #52

Artoria2e5 opened this issue Mar 1, 2021 · 3 comments

Comments

@Artoria2e5
Copy link

Artoria2e5 commented Mar 1, 2021

A significant shortfall between gpp and cpp appears to be variadic macros. People have asked for it in Fortran and in JavaScript.

This would require expanding the meta definition to have:

  • A string to indicate variadic args, ... in C
  • A string to reference variadic args, __VA_ARGS__ in C

Or an interesting alternative/parallel expansion is to expand the argument reference sequence to handle ranges. The new stuff will look like... maybe #{num}.

  • When num is just a decimal number, it stands for the nth argument.
  • When num is a decimal number prefixed by .., it stands for all arguments starting with the nth inclusive. A suffix is all arguments ending with the nth inclusive.
  • When num is two decimal numbers spearated by .., it stands for all arguments between the two numbers inclusive.

Both cases still need some magic to remove the comma with an empty expansion.

@vilkov
Copy link

vilkov commented Sep 11, 2021

Support of variadic macro would be great!

@logological
Copy link
Owner

Patches welcome.

@Artoria2e5
Copy link
Author

I seem to have worked on the #{num} thing for a while at https://github.com/Artoria2e5/gpp/tree/var, but there's no way I have tested it. I have no idea what got into my head to handwrite a state machine. Even if it works the comma magic still needs to be added -- __VA_OPT__ in cpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants