Expandable macros are useful (I find working in the lion's mouth super cool). But they are difficult to write.
Can more experienced users give hints that help achieve expandability?
For example, we cannot use counters since the value cannot be changed when expanding. However, a trick might be to keep the value of the counter as the number of
A (say) that we move around while expanding:
5 would be 'stored' as
AAAAA, and we can add counters by moving the two lists of
A together, etc. Of course, it is not efficient, but it is expandable, after all.
For definiteness, say that I want to define a macro whose argument is delimited like
\verb: the first character token determines what the end-character is, so that any of
\foo+...+, etc. are treated identically. Can I do this in an expandable way?
Any other trick is welcome.