goto

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Feb 5 20:35:20 PST 2009


Brad Roberts wrote:
> Robert Fraser wrote:
>> Which looks even worse. IMO, this is the perfect place for goto -- small
>> function, used only for an exit condition. There's no "spaghetti code"
>> here at all. I know goto used to be abused back in the day, but it has
>> its place.
> 
> Oh, I agree.  I didn't say that in my response because he specifically
> asked for other ways to write it.  In this case, I see no reason to
> change it.  That said, it can be nearly as clean without the goto for
> those that are religious about it.

Yah, same here. I seem to finally have found one of the elusive cases 
when goto simplifies things.

About Brad's variant - ranges don't define clear, but assigning b = 
b.init does the trick. (I personally still find the goto version 
marginally clearer. It's also marginally more efficient because it 
doesn't do one assignment and one vacuous check. Also the joke with the 
programmer who throws the water and then applies the known procedure to 
make coffee comes to mind.)


Andrei



More information about the Digitalmars-d mailing list