Re: Good Use of GOTO

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy Cowgar wrote:
> 
> 	if res < 0 then
> 		-- out
> 	else

Why do that? Why not

if res >= 0 then
  inode = fat_build_inode(sb_p, de_p, sinfo[I_POS], res)
  brelse(bh_p)
  ...
end if

Anyway, I prefer the one without the GOTOs as it's easier to parse.

In the one with GOTOs, at first glance, I would assume that all that code
is going to be called. But then I see the label "out" line. Now I have to
go back up into the code and find a GOTO (or more). This is, of course, a
simple example. I would HATE to see GOTOs in a function bigger than the
simple one you've posted.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu