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.

Some people use the following style

setting
{
     a=1
    ,b=2
    ,c=3    
}

and the other ones use the style below

setting
{
    a=1,
    b=2,
    c=3 
}

I use the latter style but I wonder why some people prefer the former style? Is there anything I missed?

share|improve this question
    
That's interesting. Though there are many bracing and whitespacing conventions around I haven't seen that comma convention before. –  Matthew Leingang Jun 15 '11 at 0:02
    
@Matthew: The first comma convention is very common in Haskell. –  Aditya Jun 15 '11 at 0:48

2 Answers 2

up vote 5 down vote accepted

In ConTeXt, the two are not equivalent. The former sets a to be 1\n etc. This leads to a very common beginner error:

\setupsomething
    [...]
    [ key1=value,
      key2=value,
      key3=value
    ]

Notice that the last line does not contain a comma, so key3 is set to be equal value\n. To avoid that use

\setupsomething
    [...]
    [ key1=value,
      key2=value,
      key3=value,
    ]

or

\setupsomething
    [...]
    [ key1=value,
      key2=value,
      key3=value]
share|improve this answer
    
+1 for introducing ConTeXt, I am interested in it recently. –  xport Jun 15 '11 at 1:01

Usually when setting keys you can do it this way:

{
    a=1,
    b=2,
    c=3,
}

Then all rows can be commented out and additional rows can be inserted anywhere.

share|improve this answer
    
The last row is allowed to have a trailing comma? Are you sure? –  xport Jun 15 '11 at 0:17
    
Yep, I use this in my PGFplots to comment/uncomment sections and not have to worry if I need to add or remove a comma. Very useful. –  Peter Grill Jun 15 '11 at 0:30
2  
In fact, \pgfkeys just ignores empty keys in its argument, so you can have as many superfluous commas as you like. Marginally useful when constructing argument lists from optional user input. –  Ryan Reich Jun 15 '11 at 0:42
    
+1 for confirming the trailing comma. –  xport Jun 15 '11 at 0:53
    
Another good example pertaining to superfluous commas, visit Does this compile? –  Please don't touch May 24 '12 at 17:39

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.