Re: Gotos

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

 



On Thu, Jan 08, 2004 at 05:49:17AM -0800, Phil White wrote:
> The main reason is that gotos are much more efficient than return
> code.  As a result, there is a school of thought which believes that
> every function should have one entrance and one exit.  In the kernel, 
> memory is at a premium so it makes sense to have a bunch of one
> instruction jumps to return code, rather than n different copies of
> return code for separate cases.
> 
> The goto lover in me will not let me get away without asking this
> question:  Why do gotos need a good reason to be used?  Wouldn't
> n different return statements be "harder" to read than gotos which
> all go to a common exit point?

That makes sense. I'm no programmer really, and I've only ever heard bad
things about gotos and "spaghetti-code", so that's the only reason why I
thought it looked odd. Thanks for explaining this for me.

                Tim

--
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