In other words, is bool{testB} evaluated at all in this example code?

\ifboolexpr{ bool{testA} or bool{testB} }{OK}{Something's wrong...}

(I am too lazy (pun intended;)) to check in the source, the documentation seems to say nothing about it – maybe someone just knows that and doesn't have to analyze the source (which I did look into, but didn't understand it at a first glance)? If it isn't something obvious, I'll be happy to do my homework, dig into the source and try to establish this.)

2 Answers 2


The evaluation is not lazy, revealed by scanning the .log when tracing the macro expansions:

\ifboolexpr{ bool{testA} or bool{testB} }{OK}{Something's wrong...}

That is, a complete evaluation of bool{testA} is followed by an equivalent evaluation of bool{testB}, followed by an evaluation of or, to output \@firstoftwo{OK}{Something's wrong...}.

Depending on your inspection of the macro expansion, you may require the use of a group to limit the output to the .log.

  • 4
    I'd have gone for a faster route: \ifboolexpr{ bool{testA} or bool{\ERROR} } would work with testA true and lazy evaluation, but fails so evaluation can't be lazy :-)
    – Joseph Wright
    Apr 2, 2014 at 7:21
  • 7
    @JosephWright: I see, the lazy approach to detecting whether the evaluation is lazy. :)
    – Werner
    Apr 2, 2014 at 7:23

The answer has been given by Werner. xintexpr knows about etoolbox booleans and toggles. Different syntaxes allow different levels of laziness:

[sorry I got wrong the way "lazy" was to be interpreted; thus I switch to "silly"]

  1. silly: booleans are replaced by 1 or 0 depending on whether they evaluate to true or false, and then the logical or does not stop scanning these 1's or 0's even if it has found already a true one.
  2. semi-silly: the booleans are evaluated but the or stops when it has found a true one
  3. not silly: booleans are not evaluated unless really needed.

In the code snippet below, the three different syntaxes realize the three possibilities described above:




% silly
\xintifboolexpr{ bool(testA) | bool(testB) | bool(testC) }{OK}{Something's wrong...}

% semi-silly
\xintifboolexpr{ any(bool(testA),bool(testB),bool(testC)) }{OK}{Something's wrong...}

% not silly
\xintifboolexpr{ bool(testA)?1{bool(testB)?1{bool(testC)}} }{OK}{Something's wrong...}

  • 3
    I rolled-back twice my edits... :-( I realized I had interpreted "lazy" as the opposite of its signification in the OP, then I changed my mind, then I again changed my mind. (this is all because "lazy" has a pejorative connotation, while in fact it is the intelligent thing to do; perhaps even generally ;-))
    – user4686
    Apr 2, 2014 at 8:36
  • With release 1.1 of xint ([2014/10/28]), the || for OR and && for AND are preferred to single | and &. One can also use 'or', 'and', 'xor' (straight quotes mandatory).
    – user4686
    Nov 29, 2014 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.