pre-RFC, 'gather macro'

any thoughts on this idea, a ‘gather’ feature in the macro system, allowing macros to collect information from elsewhere, or allowing pieces of recursive macros to be collected

any other ideas on how to achieve the goals here? I know the existing macro system is very capable.

1 Like

Cargo does something similar for subcommands with a high order macro: https://github.com/rust-lang/cargo/blob/eb6cf012a6cc23c9c89c4009564de9fccc38b9cb/src/bin/cargo.rs#L101-L134

You still are required to explicitelly list all the entries in one place, but then you can use arbitrary macros to process them.

reminiscent of the x-macros trick in C, but obviously a lot more sane here.

So basically this is an example of a case where a ‘gather macro’ might help (generating that list). i guess in that case you could probably avoid the need to ‘maintain the list’ by embedding all the original code in the macro, but gathering from multiple source files would be saner for project organization

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.