Best way to define a macro that does something for each argument?

the standard $(xs:expr),+ pattern struggles to deal with trailing commas, which can be solved by adding another case, but that involves quite a lot of repetition. it there a more elegant way of handling this?

1 Like

That pattern forbids trailing commas. If you want to require trailing commas, you can do $($xs:expr,)+, and if you want it to be optional, you can do $($xs:expr),+ $(,)?.

2 Likes