First of all: I never knew about environ
and am impressed. My answer is not nearly so good, but I learned it from the LaTeX sources so it should count for something.
Try writing
\newenvironment{<stuff>{\iffalse}\fi}
{\iffalse{\fi}<stuff>}
<stuff>
, of course, is what you wrote. The point is that there are no unbalanced braces in this construction, because when parsing macro arguments, TeX does not actually expand anything, in particular, \iffalse
. Thus, the "commented out" braces are present for the purposes of reading in the contents of the environment commands, and then absent for the purposes of executing them.
EDIT: In this and many other cases, the much simpler expedient of \bgroup...\egroup
works too:
\newenvironment{<stuff>\bgroup}
{\egroup<stuff>}
Since \bgroup
is \let
to equal {
and \egroup
is \let
to }
, this (in theory) is synonymous with using braces, except that (since these "implicit characters" don't count as far as nesting inside arguments being parsed is concerned) it doesn't break definitions.
Occasionally you come across a situation where literal braces are required; \def
itself is an example. You must write
\def\cs{<def'n>}
and not
\def\cs\bgroup<def'n>\egroup
but in many higher-level constructions (including, my quick test shows, TikZ) this is not a problem.