lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lilypond-book: treat iffalse sections in latex as block comments (is


From: David Kastrup
Subject: Re: lilypond-book: treat iffalse sections in latex as block comments (issue 6584073)
Date: Sat, 06 Oct 2012 14:58:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux)

Reinhold Kainhofer <address@hidden> writes:

> On 2012-10-06 06:33, address@hidden wrote:
>
>> http://codereview.appspot.com/6584073/diff/1/python/book_latex.py#newcode88
>> python/book_latex.py:88: \\iffalse.*\\fi))''',
>> As David has commented on the list, I would prefer if you replaced the
>> \iffalse ... \fi with a higher-level command, namely \begin{comment} ...
>> \end{comment} (from the `comment' package).
>
> So, your opinion is that lilypond-book SHOULD process the
> \lilypond{...} code inside the \iffalse  section and spectacularly
> fail.

Reality check: lilypond-book does not "spectacularly fail".  It
processes the included snippets which LaTeX then just skips.
lilypond-book just takes unnecessary effort.

> If users are using \iffalse -- I am for example one of those who use
> \iffalse to quickly comment out some parts temporarily -- then
> lilypond-book would still require everything between \iffalse and \fi
> to be in correct lilypond syntax and will create snippet images for
> all those snippets:

Exactly.

> \documentclass[a4paper, 12pt]{article}
> \begin{document}
> TODO
>
> \iffalse
> This is a template for my future snippets:
> \lilypond{Code comes here}
> \fi
>
> \end{document}
>
> Shall lilypond-book really fail for (and process) snippets that will
> NOT be included by latex???

\iffalse\fi is not a LaTeX sequence.  If it were, there would be little
excuse _not_ to heed its inherent nesting, like TeX does.  If you write
\iffalse
\ifverbose Hey this is nice!. \fi
This is a template for my future snippets:
\lilypond{Code comes here}
\fi

then lilypond-book will spectacularly fail as it, as opposed to
TeX/LaTeX, is not able to properly match \if...\fi.

Using and heeding the comment environment, in contrast, does not suffer
from that problem.

>> First of all, this syntax
>> suits LaTeX better since it resembles normal environments.  Second, it
>> is a bad idea in general to expose \ifXXX to the top level; in other
>> words, users should never do that.
>
> But fact is, people ARE using \iffalse to temporarily comment out
> larger parts of latex files. With my colleagues, I have never seen
> \begin{comment} for comments, all the researchers I have worked with
> so far were using \iffalse.
>
> Also, this is not about advocating what latex users should use, but
> handling whare users are using currently. So, I will add
> \begin{comment} to the pattern, too, but I still think that
> lilypond-book SHOULD ignore everything inside \iffalse.

The problem is that lilypond-book has _no_ way to figure out just _what_
is supposed to be "everything inside \iffalse" if you ever actually
start using TeX conditionals for any other purpose than outcommenting
code.

>> Reason is that \ifXXX is handled
>> very special in TeX since you can define, say, \ifFoo which also pairs
>> with the next \fi, making correct balancing of nested \ifXXX commands
>> quite delicate and very hard to debug.
>
> Sure, it's not the perfect way, but it's the quick-and-dirty way.

> I'm also aware that lilypond-book will not be able to handle nested
> \ifXXX correctly. However, in the worst case, it will process some
> code after the first \fi and before the final \fi of the \iffalse. But
> that's still better than the current situation, where it processes
> everything between \iffalse and \fi.

I disagree.  lilypond-book is not smart enough to know about the LaTeX
structure of the document.  If you want smart processing of typeset
material, the lilypond environment would have to be processed by LaTeX
rather than replaced by lilypond-book acting as a preprocessor.

That would be nice to have and obliterate the need for a separate .lytex
file, but it would also make it unfeasible to use lilypond environments
and commands nested in contexts (like in macro arguments) where LaTeX's
\verb and other "verbatim-like" constructs would also experience
problems.

-- 
David Kastrup



reply via email to

[Prev in Thread] Current Thread [Next in Thread]