LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Fri, 7 Aug 2015 18:44:34 +0200
Reply-To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Subject:
MIME-Version:
1.0
Message-ID:
In-Reply-To:
Content-Type:
text/plain; charset=UTF-8
From:
Bruno Le Floch <[log in to unmask]>
Parts/Attachments:
text/plain (57 lines)
Hi Sean, hi all,

Thank you for your thoughts.  I arrive at the following proposal: no
lazy evaluation by default, and provide \bool_or_p:nn and
\bool_and_p:nn for lazy evaluation (perhaps even called
\bool_lazy_or_p:nn and \bool_lazy_and_p:nn).  The example you gave
would become

> A and B will short-circuit as they do today.  If A is false, B through
> E will not be evaluated.  If A is true and B is false, ... etc.
>
> If ( A && B && !C), we'll get to [...] *without* short-circuiting.

    \bool_if:nF
      {
        \bool_and_p:nn
          { \pbj_is_peanut_butter_jelly_time_p: }               % (A)
          {
            \bool_and_p:nn
              { \pbj_can_dance_p: }                                 % (B)
              {
                ! \bool_or_p:nn
                  { \pbj_has_suit_p:N \g_tmp_person }            % (C)
                  {
                    \token_if_eq_meaning_p:NN #1 ? ||         % (D)
                    \token_if_eq_meaning_p:NN #1 !            % (E)
                  }
              }
          }
      } { dance ~ like ~ there's ~ no ~ tomorrow }

Alternatively to get less nesting in long lists of A && B && C && D &&
E && F, we could provide \bool_and_p:n and \bool_or_p:n in which tests
are wrapped in brace groups,

    \bool_and_p:n
      {
        { \test_one_p: }
        { \test_two_p: }
        { \test_three_p: }
        { \test_four_p: }
      }

We could even provide both \bool_and_p:nn for binary && and
\bool_and_p:n for lists, but perhaps it gets confusing that the two
are only distinguished by their signature :nn or :n.

I'd rather not provide myself a parser for lazy evaluation of boolean
expressions (e.g., an implementation of the shunting yard algorithm as
you mention).

Does that seem like a good plan?

Regards,

Bruno

ATOM RSS1 RSS2