Re: [exim-dev] Use of 'goto' in Exim sources.

Inizio della pagina
Delete this message
Reply to this message
Autore: Philip Hazel
Data:  
To: David Wilson
CC: exim-dev
Oggetto: Re: [exim-dev] Use of 'goto' in Exim sources.
On Tue, 9 Aug 2005, David Wilson wrote:

> I notice that in my Exim 4.32 tree there are 345 other gotos, suggesting that
> Philip doesn't mind the use of goto (well, judiciously, at least). Is this the
> case?


I typically use goto only when I want multiple (usually error) exits
with cleanup code from within some block, or when I need to escape from
nested loops or a switch within a loop (for which C does not provide a
natural exit mechanism - when it was developed from BCPL it broke this
by overloading "break"; BCPL differentiated between "break" and
"endcase").

99% of my gotos are forward jumps; only very, very rarely do I use one
to jump backwards, though there are occasions when this is the neatest
way to say what you want. I always use uppercase labels, so they stand
out.

So yes, you are right, I don't mind the use of goto when it is the
cleanest way to express something, but I try to avoid it in the normal
run of code, reserving it mostly for "oops, we've hit a error state, get
the heck out of here" situations.

-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book