Sender: |
|
Date: |
Fri, 7 Aug 2015 18:44:34 +0200 |
Reply-To: |
|
Subject: |
|
MIME-Version: |
1.0 |
Message-ID: |
|
In-Reply-To: |
|
Content-Type: |
text/plain; charset=UTF-8 |
From: |
|
Parts/Attachments: |
|
|
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
|
|
|