DEV Community

Discussion on: Is This Snowflake Code?

Collapse
 
tgiddings profile image
Trevor Giddings

The indentation of the braces in the last code sample is very difficult for me to read. The ending braces to me appear to end a different block than they really do. I see the first ending brace as a stray and I think there is a missing brace when I look at the end. At a glance, statements appear to be in very different blocks than they really are.

The spacing before the semicolons looks "funny" to me since I see semicolons as a kind of coding punctuation and punctuation never has a space before it (at least in English), but the spacing is still perfectly legible and intelligible.

Collapse
 
jsn1nj4 profile image
Elliot Derhay

Wonder if your point about the closing braces is why the edited code on SO stopped working. Maybe someone really did get confused when editing and accidentally broke it.

Collapse
 
jacoby profile image
Dave Jacoby • Edited

I see the braces going with the indented code, not the surrounding code. So, I would do this:

    {
    my $code = code_goes_here() ;
    }

over

{
    my $code = code_goes_here() ;
}

I started doing the ; thing so that, if I was copy-and-pasting a variable, I wouldn't also get the semicolon, but that's a carry-over from highlighting in a terminal window and paste-or-middle-button. It was the 1990s, and I don't think editors behave like that anymore.