LATEX-L Archives

Mailing list for the LaTeX3 project


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
Joseph Wright <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Sun, 5 Jan 2020 22:47:03 +0000
text/plain (38 lines)
On 03/01/2020 21:56, Kelly Smith wrote:
> A happy New Year to everyone!
> After a long hiatus, I’m finally able to resume working with LaTeX. Of course, this means that I’ll be popping up, with questions, at regular intervals: my apologies, in advance.
> If this question would be better-posed on tex.SX, please let me know, and I’ll move it there.
> I am considering the following (generic) problem… I have a function that is meant to do something with a list of words/numbers/&c. Naturally, I would use a sequence, to represent the list, at the code level. I decide that, at the author level, a semicolon-separated list will be the syntax to use for the list.
> Now, I have two commands:
> — The author-facing command `\makelist{foo; bar; baz}`
> — The internal command `\ks__make_list:<?>`
> As you can see, from the function signature, I’m not sure what the internal command should expect. There is no way to, say, generate a sequence literal, and pass it as an `n` type argument. I could pass the semicolon-separated list, untouched, and have the internal function split it into a sequence. However, that would break the syntax-code separation.
> Would it be better to have a local variable, `\l__ks_make_list_a_seq`, and set it before calling `\ks__make_list:`?
> If that is the case, should I follow a the same approach for other, similar situations?
> Warmly,
> Kelly

\makelist is a document command so if there is no additional complexity 
couldn't you use xparse to convert to an open-ended tl and then map to that?

     \DeclareDocumentCommand \makelsit { > { \SplitList { ; } m }
         \tl_map_function:nN {#1} \ks_process_list:n

If not, for more complex cases, I'd end up with the same thing but at 
the code leve: a documented \ks_list:n taking { a ; b ; c } and doing 
the split itself: the kind of thing siunitx has to do.