octave-maintainers
[Top][All Lists]
Advanced

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

Re: goto vs. return?


From: John W. Eaton
Subject: Re: goto vs. return?
Date: Mon, 25 Jan 2016 14:35:45 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0

On 01/25/2016 01:26 AM, al davis wrote:
On Sun, 24 Jan 2016 07:55:49 -0800
Rik <address@hidden> wrote:

I don't think much of goto, but I do accept intermediate returns as a valid
style.  What I dislike is the Arrow coding style
(http://blog.codinghorror.com/flattening-arrow-code/) of which there is a
lot.  Early returns, a.k.a guard statements, are one way of reducing
massive indentation.  One versus multiple returns seems to be something
that programmer's like to debate.

I think the real answer is to understand what you are trying to
accomplish, then express it as clearly as you can.

It looks a lot worse with that curly-brace style.
Once-upon-a-time, Gnucap did use that style, but I changed it to put
the curlys on the "if" line.

Also, the way "else if" is written there adds several lines.

Also ..  I like to make the empty else explicit, and always use curlys.

Changing these things alone makes it look a lot better:

Better to you, perhaps. I don't think there is anything universal about what looks better and what doesn't. "Use some freaking whitespace, dude!" is my reaction to the code snippet you posted. Also, it looks bad to sometimes have whitespace before/after the curly brace and sometimes not. Is that intentional? I also find it harder to read things when code is all smashed together. But maybe the way I view code is different from you? I sometimes read without syntax highlighting and in black an white.

jwe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]