...

iainmerrick

6223

Karma

2014-03-11

Created

Recent Activity

  • I think this boils it down to the essence. Whether you use a trailing comma here, and whether you use single or double quotes, is just bike-shedding. If there's an automated tool that can make a consistent choice everywhere, that's worthwhile.

  • I don't see "pietnas" anywhere; do you mean the "important_numbers" example from maratc?

    If so, I think a trailing comma is the correct fix, as described here: https://news.ycombinator.com/item?id=45168308

    In this case I think the trailing comma is an improvement, so the formatter is steering you towards a better overall solution. However, even if you dislike the trailing comma, it's more important for the formatting to be consistent and robust, so I still think it's better to work within the limitations of the formatter.

  • It can’t be just that, surely? Or the more traditional sloped fronts would be gone completely.

    I don’t think people are buying these because they’re safer for pedestrians, they’re buying them because they like the way they look, and/or because they (the drivers) feel safer when they’re in a huge box sitting high up, looming over the surrounding cars.

  • It works the way you want if you add a trailing comma:

      important_numbers = {
        "x": 3,
        "y": 42,  # Answer to the Ultimate Question!
        "z": 2,
      }
    
    You might complain that that seems a bit obscure, but it only took me 10 or 20 seconds to discover it after pasting the original code snippet into an editor.

    The trailing comma is an improvement as it makes the diff clearer on future edits.

    Edit to add: occurs to me that I oversimplified my position earlier and it probably looks like I'm trying to have it both ways. I do advocate aiming for clean and clear formatting; I'm just against doing this manually. You should instead use automation, and steer it lightly only when you have to.

    For example, I explicitly don't want people to manually "tab-align" columns in their code. It looks nice, sure, but it'll inevitably get messed up in future edits. Better to do something simpler and more robust.

  • I don't think we'll ever fully agree, but I'd just like to clarify that I value that kind of craftsmanship too!

    I just honestly believe that if you fully automate the formatting, the results are better than if you do it painstakingly by hand; better by virtue of being more consistent. It's using the right tool for the job.

HackerNews