## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

 Options: Use Forum View Use Monospaced Font Show Text Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

Andreas Matthias writes:
> >
> >> I struggled a while to understand how to use \prg_whiledo:nT.
> >> I think I figured it out, but it seems to be rather clumsy:

[..]

> Yes, I missed it, too. But maybe one doesn't need it? At least, if
> one uses \prg_whiledo:nT in a straight-forward way as in:
>
> > The entire test could be simplified to
> >
> > \prg_whiledo:nT {
> >   \predicate:nT{
> >     \int_compare_p:nNn \a_int < 4 &&
> >     \c_true % some complex tests here
> >   }
> > }{
> >   \io_put_term:x{Loop~ \int_use:N \a_int}
> >   \int_incr:N \a_int
> > }
>
> Oh, yes. That's it: \predicate:nT. That's what I was looking for.
> But yesterday I stubbornly sticked to \predicate_p:n again and again.
>
> >> In xtheorem.sty it is used as:
> >>
> >>     \prg_whiledo:nT{
> >>       \int_compare:nNnT \etex_lastnodetype:D = \c_eleven
> >>     }{\tex_unskip:D}
> >>
> >> And actually, this was the way it expected it to work? But
> >> it doesn't work, does it? I didn't run xtheorem.sty, though.
>
> Well, again I was misleadingly thinking of \int_compare_p:nNn.
> But \int_compare:nNnT succeeds, of course.

just got around reading that and somehow I don't think this syntax is right

just a minute ago I coded

\prg_whiledo:nF
{\seq_if_empty_p:N \g_xor_floats_active_seq }
{
\seq_gpop:NN \g_xor_floats_active_seq
\g_xor_curr_float_box_tlp
\xor_extract_this_float_values:N  \g_xor_curr_float_box_tlp
}

using this function for the first time and that gave some surprising results
(for me) ... then looking at the implementation of \prg_whiledo:nF and this
discussion not so surprising.

But I don't think that:

> The idea behind these generic constructs is to have input as
>    \prg_whiledo:nT {% or F
>      <various stuff>
>      \some_test_function:..T % or :..F
>    }
>    { <true code> }
>

this is memorable syntax. it is kind of the mixture between \loop \repeat
syntax idea and the argument based TF ideas.

And it doesn't go too well with something like

\bool_whiledo:NT

------------

I'm not saying that the construct as such isn't useful (though it is playing
somewhat badly on the argument stack as this isn't tail recursion, is it?)
but I don't think the syntax fits well though I don't have a good alternative
suggestion right now ...

frank

ps ... seems that there has been some documentation change recently ...in my
hard copy that I use here the exact requirements about using T or F functions
for the test aren't written down  ... reading that helps :-)