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
Show All Mail Headers

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

Print Reply
Subject:
From:
Alexander Grahn <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Fri, 11 Sep 2015 12:53:51 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
On Fri, Sep 11, 2015 at 11:21:56AM +0100, Joseph Wright wrote:
>On 11/09/2015 11:17, Alexander Grahn wrote:
>> On Fri, Sep 11, 2015 at 11:06:08AM +0100, Joseph Wright wrote:
>>> On 11/09/2015 10:46, Alexander Grahn wrote:
>>>> consider the following example:
>>>>
>>>>   \documentclass{article}
>>>>   \usepackage{expl3}
>>>>   
>>>>   \begin{document}
>>>>     \ExplSyntaxOn
>>>>       \clist_set:Nn\l_tmpa_clist{,,foo,bar,}
>>>>       \typeout{\clist_count:N\l_tmpa_clist}    %expected:  5,    I get 2.
>>>>       \typeout{\clist_item:Nn\l_tmpa_clist{3}} %expected: `foo`, I get `'.
>>>>       \typeout{\clist_item:Nn\l_tmpa_clist{4}} %expected: `bar`, I get `'.
>>>>     \ExplSyntaxOff
>>>>   \end{document}
>>>>
>>>> Why does \clist_set:Nn ignore empty items when initialising a clist
>>>> variable from a token list? Is this intended behaviour? Is there a
>>>> work-around?
>> 
>>> This is by-design. Comma lists can't contain empty items, commas, etc.:
>>> sequences can. The reason is comma lists are 'close' to the user level,
>>> and there stray empty entries are normally best ignored.
>> 
>> This is very unfortunate, because I want to be able to correctly process
>> user input of comma sparated items which /may/ contain empty items.
>> 
>> With \@for from LaTeX2e I can easily process such input properly:
>> 
>>   \documentclass{article}
>>   
>>   \begin{document}
>>     \makeatletter
>>      \@for\listitem:=,,foo,bar,\do{
>>        \typeout{item:\listitem}
>>      }
>>     \makeatother
>>   \end{document}
>> 
>> Now I am looking for an L3 equivalent of \@for.
>> 
>> Alexander
>
>Can of course be done using a sequence
>
>    \input expl3-generic %
>    \ExplSyntaxOn
>    \seq_set_split:Nnn \l_tmpa_seq { , } { ,,foo,bar, }
>    \seq_show:N \l_tmpa_seq
>

Perfect! Thanks a lot!

Alexander

ATOM RSS1 RSS2