Hacker News new | ask | show | jobs
by stormbrew 4864 days ago
This is actually one of the worst things about it to me, other than the lack of comments. A language that has comma-separated lists and doesn't allow trailing commas on the list as a whole is frustrating to use in a version controlled context because adding an item requires modifying the item before, which leads to more (and less obviously solvable) merge conflicts.
1 comments

I've seen a style of list initialization that sort of addresses this issue. I like it, but I don't see it used very often. Darn you standards!

    kittyBreeds = ["Himalayan"
                  ,"Bengal"
                  ,"Siamese"
                  ,"Burmese"
                  ,"Cornish Rex" //rawr
                  ,"LaPerm"
                  ,"Manx"  
    
    //This is not a real cat! >:(
    //              ,"lolcat"
                  ,"Munchkin"
                  ,"Ocicat"
                  ];
In this way the issue with the commas is relegated to the first element, rather than the last. Since appending is more common, this seems a better style.
Interesting approach. This strikes me as kind of like the classic "put the constant on the left" advice in C/C++ that, no matter how many people agree it's a good idea, no one ever does because the cognitive effort of understanding it is high enough to diminish the correctness benefit.

In other words, you know you're just gonna end up with this in your code after a few months:

kittyBreeds = ["Himalayan", ,"Bengal", "Siamese", "Cornish Rex", ,"Manx"]

and not only is it now even worse for changing lines (correcting it and adding another will be -1+3 instead of just -1+2, the optimal +1 a distant memory), but it's just plain a mess and probably people don't know why they need to do it.