From: Chad Perrin Date: 2010-10-15T00:37:28+09:00 Subject: Re: Why does a lot of code not include parenthesis? --kORqDWCi7qDJ0mEj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 11, 2010 at 03:21:22PM +0900, Phillip Gawlowski wrote: > On Mon, Oct 11, 2010 at 6:04 AM, egervari wrote: > > > > Of course, once one gets used to it, I guess it'll become readable. >=20 > Absolutely. A seasoned Perl vet will consider Perl code very readable, > too, after all. ;) Only well-written, readable Perl is particularly readable, even to a "seasoned Perl vet" -- just as only well-written, readable Ruby is particularly readable, even to a "seasoned Ruby vet". Taking an example like what was brought up earlier, there are a bunch of different ways to represent a complex expression: 1. 10.div(10.div(5)) 2. 10.div( 10.div(5) ) 3. 10.div 10.div 5 4. 10.div(10.div 5) 5. 10.div( 10.div 5 ) 6. 10.div 10.div(5) There are other options as well, but I have to stop some time. Anyway, in my opinion, the *worst* of those for readability are 1 and 3. 2 and 6 are probably the next least-readable. It takes a little judgment to write readable code, regardless of the language, and in cases where parentheses are optional, I find that obsessive adherence to "always use parentheses" or "never use parentheses" rules are not conducive to producing the most readable code. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --kORqDWCi7qDJ0mEj Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAky3Io8ACgkQ9mn/Pj01uKUFTgCg5lzds7sCzGXtCLoW5S3pYyW9 3J4An2lOUDm5miXtlnK2BLBFxSJLaFHd =t+kX -----END PGP SIGNATURE----- --kORqDWCi7qDJ0mEj--