Hans van der Meer wrote:
Therefore I conclude to the following: on inspecting the next character with "\doifnextcharelse[%" the character which is compared is the &.
It is more technically correct to say that the \doifnextcharelse compares the first token of the expansion of '&' with the second token of the expansion of '&'. Down this road awaits madness. In general, you can not intermix optional arguments and active characters, you need to have at least one non-active non-space token to break off the search in a reliable manner. Simply adding a \relax statement sounds like the simplest solution.
Being not equal to [ it is given back but -- if I remember well -- there can be a catcode problem. I guess & still functions as separator in the \halign template but no longer functions as a macro, as it should in my code.
There might be no solution for this within TeX's limitations. But maybe you can confirm cq. deny that from your knowledge of TeX (which certainly is greater than mine).
There is a chance that there is a hackish way around this limitiation for some very specific cases, but i cannot tell without the actual code you use. Taco