lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATCH: Refactor script-column.cc for improved reading and fewerlines


From: Reinhold Kainhofer
Subject: Re: PATCH: Refactor script-column.cc for improved reading and fewerlines
Date: Fri, 4 Dec 2009 19:49:55 +0100
User-agent: KMail/1.12.2 (Linux/2.6.31-15-generic; KDE/4.3.2; i686; ; )

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Freitag, 4. Dezember 2009 18:24:01 schrieb Trevor Daniels:
> David Kastrup wrote Friday, December 04, 2009 4:24 PM
> 
> > I've unwrapped a bit of code of the form
> >
> > for (a;b;c) {
> >  if (condition)
> >    short something
> >  else {
> >    Large something
> >  }
> >  z
> > }
> >
> > into
> >
> > for (a;b;z,c) {
> >  if (condition) {
> >    short something
> >    continue;
> >  }
> >  Large something
> > }
> >
> > which helps a bit keeping track of what happens where.
> 
> I disagree.  Hiding the z in the iteration clause means
> it is likely to be overlooked.  Also the use of continue
> rather than else does not clarify the structure IMO.

+1

To me continue clauses are like goto statements. I try to avoid them whenever 
possible. Only in some extreme cases where I would get like 12-times indented 
code, then its better than else...

When reading some code long afterwards, it's quite easy to miss a continue or 
return (the two pathes of an if are indented and thus easy to spot) and then 
wonder why some statement apparently has no effect.

Cheers,
Reinhold
- -- 
- ------------------------------------------------------------------
Reinhold Kainhofer, address@hidden, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFLGVnUTqjEwhXvPN0RAqovAKDS/7/q5S+2Zerx9vlTf2rh9QlYSgCgsDZt
tzSVasyeJMgyuH15Qy+aMeI=
=T+hB
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]