Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: My coding guidelines

by Courage (Parson)
on Nov 25, 2002 at 19:36 UTC ( #215713=note: print w/ replies, xml ) Need Help??


in reply to My coding guidelines

I am not agreed with item (25):

There SHOULD be whitespace between an indentifier and its indices. There SHOULD be whitespace between successive indices.
I see everywhere $array[$index] or $hash[$index] without any whitespaces and accustomed to this. IMHO Most perl core and CPAN modules do not satisfy that rule.

I see no readability problems with such a very standard situation of array or hash indicies.

I do agree on all other items though.

Courage, the Cowardly Dog


Comment on Re: My coding guidelines
Select or Download Code
Replies are listed 'Best First'.
Re: My coding guidelines
by Abigail-II (Bishop) on Nov 26, 2002 at 10:40 UTC
    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

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://215713]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2015-07-29 21:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls