[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn_stream_copy3() in svn_io.h

From: Greg Stein <gstein_at_gmail.com>
Date: Wed, 8 Apr 2009 06:20:24 +0200

On Wed, Apr 8, 2009 at 05:19, Edmund Wong <ed_at_kdtc.net> wrote:
>...
> I've been reading a bit of code and came across these goto usage.
> No offense, but, I don't think I have seen that many gotos

Ha! Seriously. Don't worry about offending me. Lay it on. I've had
people call me all kinds of things, but that doesn't bother me when
we're trying to create some kickass code. There are interpersonal
things, and there is code. And you probably can't raise my temperature
on either one.

> in a long time.   Rather than talk about the ingrained teachings
> of not using goto's in any program; I think it's better for me
> to understand the rationale.   Again, I meant no offense to
> anyone here.  I'm just quite surprised by the usage of goto
> and really need some sort of clarification.  (I think the
> last goto I saw was in a BASIC program I did a long time
> ago.)

Proper use of goto can greatly simplify a function. Bending over
backwards to create if/else sequences or flags or whatever... just in
order to note "cleanup" status ... can be much more complicated than a
simple goto.

You'll also note that nearly all goto operations in the svn codebase
are for exit cleanup. The classic "goto problem" is based around using
goto as a control mechanism. When it is limited to just cleanup/exit,
then it becomes a fancy "return" statement. Not really a goto.

>> Propagating the error is correct. You nailed that one. But it is
>> possible that somebody will decide to ignore/discard the error as
>> "allowable". The program won't necessarily exit. Thus, the advertised
>> "will close" still needs to be met.
>
> While my code wasn't as succinct nor concise, it had a similar
> feel; but I don't know if I captured the essense right.  I think
> I'll need some sort of peer-review of my lousy C coding.

Not a problem. Just post your patches. Seems they've been getting enough review.

Cheers,
-g

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1589600
Received on 2009-04-08 06:20:42 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.