http://www.perlmonks.org?node_id=215816


in reply to Re: My coding guidelines
in thread My coding guidelines

I know many people will disagree with rule 25. But they are my guidelines, and that's the way I code. Not just in Perl, but any language that I can remember programming in allows whitespace between an indentifier and its indexing operation. Including Python. (Unfortunally, Perl 6 will break decades of tradition).

The reason is that the eye needs resting points. Whitespace makes it easier to divide a line of text into chunks and read it. As well as in natural languages as in code. $foo{bar}[17]{baz} is one big blob, and it's hard to divide it into its 4 chunks, specially when the subscripts are a bit more complex. We don't have the tendency to chain words together in English (unlike in for instance German). Why should we with code?

Abigail

Replies are listed 'Best First'.
Re^2: My coding guidelines
by Aristotle (Chancellor) on Nov 27, 2002 at 17:17 UTC
    Funny, I tend to put the whitespace inside the curlies and add extra arrows in that case, as in $foo{ $something_really_long }->{ and_rather($complicated)->{here} }
    which I find more helpful than $foo {$something_really_long} {and_rather($complicated)->{here}}

    Makeshifts last the longest.