Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

LaTeX3 provides the two modules seq and clist.

What is the difference?

The module clist is introduced by

Comma lists contain ordered data where items can be added to the left or right end of the list.

The module seq is introduced by

LaTeX3 implements a “sequence” data type, which contain an ordered list of entries which may contain any balanced text.

What are the benefits and drawbacks of the modules?

share|improve this question
add comment

1 Answer 1

up vote 24 down vote accepted

The two modules share a lot of features, and at there are many tasks which can in principle be tackled using either. To understand the reason for the existence of both, I'll first highlight what seq can do that clist cannot.

A comma-separated list looks something like

a,b,c,d,,

which means that most obviously the items cannot contain a comma (without brace protection). On the other hand, the seq data type is constructed such that an item may contain any balanced text. That includes not only commas, but also crucially empty entries.

The latter point occurs because a comma list is essentially a 'user facing' structure, whereas a sequence is meant for programmers. You'll also see this if you try adding a space to a comma list: spaces are trimmed from comma list items, and so something like

a, b , , c , d

is treated identically to

a,b,c,d

As sequences have an internal structure to support programmers, it's also possible to optimise the implementation rather more than it is for comma lists. That has consequences for performance in some cases.

So in terms of which is appropriate, I would favour comma lists when dealing with stuff toward the user level, for example where user input/output is required. On the other hand, totally arbitrary lists of items are better handled as sequences. There is an element of personal preference in the middle ground (where both will work).

In the past, I have suggested dropping clist functions entirely except for a conversion layer (so that we would have a single 'true way'). However, if cases where basically everything can be handled using a comma list there is a performance hit to this that is hard to justify.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.