I'm getting errors whenever I try to make \textbf interact with pgffor and xparse. Here's an MWE that gives ERROR: Extra \else and ERROR: Missing control sequence inserted at the end of the \coljoin invocation (the missing control sequence turns out to be \inaccessible). Using \flang in place of \textbf works as expected.
\usepackage{pgffor}
\newcommand{\coljoin}[1]{%
\let\acc\empty%
\foreach \x in #1 {%
\xdef\acc{\acc & \textbf{\x}}}%
\acc}
\newcommand{\llist}{a,b,c,d,e}
\newcommand{\flang}[1]{#1+1}
\begin{tabular}{cccccc}
\coljoin{\llist}
\end{tabular}
Does anyone have insight as to what \textbf is doing that interacts with the programming utilities?
The actual goal is to have some list of data whose changes propagate throughout the document without me having to do extra column counting etc. I'd like to bold some of the rows that would be generated in this way. I would most appreciate solutions that allow \coljoin to take an optional argument that is mapped over the data before it is joined (i.e. invoke as \coljoin[\textbf]{\llist} or \coljoin[\flang]{\llist}).
Extra attempts: I have tried using the same accumulator strategy, but with \multido and docsvlist. They both behave normally for non-bolded values and give the \inaccessible error for the bolded value.



