Re: Re: Gotos

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

 



This is flame bait.  As a result, I promise only one reply to it, should I
receive criticism.  That way, it needn't annoy everyone else very much ; )
--------------------------------------------------------------------------
Actually, if you try compiling that file with the patch and without it,
they do not turn out the same.  I tried without -O, with -O2, and with -O3.

In all cases (on my x86), it turns out in favor of the goto.

Your reply smacks of a rather distasteful approach towards gotos: That they
shouldn't ever be used.  Gotos have a definite use as Knuth pointed out in 
his response to Djikstra.  

That it doesn't matter is clearly false given this snippet of code.  It
saves code space.

Does it make the code any less readable to have it exit at a common point?

In my opinion, I've found multiple exits harder to track down than gotos
pointing at a common exit point in code.

The label in this case is well chosen.  "out" is pretty obviously leading
out of the function.  I don't think this qualifies as spaghetti code seeing
as how it jumps to a well defined label and out.  

As it is now, it is quantifiably better to use gotos here rather than returns.
I don't think readability is hurt at all by it.

-Phil/CERisE

On Thu, Jan 08, 2004 at 03:55:04PM +0200, Momchil Velikov wrote:
> >>>>> "Tim" == Tim Cambrant <tim@cambrant.com> writes:
> 
> Tim> Could someone please explain to me why we have a bunch
> Tim> of gotos where they really could be removed? I'm sure
> Tim> there is a good reason, but I simply don't see it. For
> Tim> example, why shouldn't the following patch be applied?
> Tim> I'd appreciate any explanation I could get. Thank you.
> 
>   Because someone thought he's smarter than the compiler.  Which may
> have been true at the time.  Nowdays it probably does not make any
> difference -- the compiler would generate the same code in either
> variant (though probably different on different architectures).
> 
> ~velco
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux