[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: goto vs. return?
From: |
LachlanA |
Subject: |
Re: goto vs. return? |
Date: |
Fri, 29 Jan 2016 20:49:50 -0800 (PST) |
John W. Eaton wrote
> On 01/25/2016 01:26 AM, al davis wrote:
>> On Sun, 24 Jan 2016 07:55:49 -0800
>> Rik <
> rik@
> > 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
The Octave style has grown on me, but when I first saw it, I thought there
was too much white space. I usually work on a notebook, and want to see a
reasonable amount of code at once. When I look at code with essentially a
blank line on every second line, I think "why not use a font that has the
whole glyph in the bottom half of the character?". The benefit of a style
that doesn't force much white space is that white space is much more
effective for demarcation.
I have read that real programmers don't care what style is used as long as
it is consistent, but if there were ever a vote, I'd vote for a more compact
style (with the exception of space to line up almost identical text on
consecutive lines; I find that makes it much easier to spot the
differences).
Cheers,
Lachlan
--
View this message in context:
http://octave.1599824.n4.nabble.com/goto-vs-return-tp4674494p4674576.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
- Re: goto vs. return?, (continued)
- Re: goto vs. return?, LachlanA, 2016/01/24
- Re: goto vs. return?, Kozma, Endre, 2016/01/24
- Re: goto vs. return?, al davis, 2016/01/25
- Re: goto vs. return?, Michael Godfrey, 2016/01/25
- Re: goto vs. return?, John W. Eaton, 2016/01/25
- Re: goto vs. return?,
LachlanA <=
Re: goto vs. return?, John W. Eaton, 2016/01/25