guess this is a case of \protected being harmful

Am 04.04.2016 um 18:16 schrieb Julien RIVAUD (_FrnchFrgg_):

> \NewDocumentEnvironment{foo}{m}{%
>      \begin{tabular}{#1}%
> }{%
>      \end{tabular}%
> }
>
> \begin{document}
>
> \fbox{
>      \begin{foo}{ccc}
>          \hline
>          Test & a & b \\
>          \hline
>      \end{foo}
> }
>
> \fbox{
>      \begin{tabular}{ccc}
>          \hline
>          Test & a & b \\
>          \hline
>      \end{tabular}
> }
>
> \end{document}
>
> The first and second \fbox-es should produce the same output, but don't:
> the foo environment starts a second line at closing time, before the
> control is passed to the author-supplied closing code.

actually that's not equiv, equiv would be something like defining "baz"

\newenvironment{baz}[1]{%
     \begin{tabular}{#1}%
}{%
     \end{tabular}%
}

but yes, same difference

reason is the following difference in processing:

\show\endfoo
\show\endbaz

 > \endfoo=\protected macro:
->\environment foo end aux .
l.10 \show\endfoo

?
 > \endbaz=\long macro:
->\end {tabular}.
l.17 \show\endbaz

the  \protected hides the \crcr inside \endtabular.

Now it may be that the protected is needed for other reasons (hope not) 
but perhaps it is just overprotection .. let Joseph say :-)

frank