From: Tim Streater on
On 26/02/2010 09:26, Kelsey Bjarnason wrote:
> [snips]
>
> On Fri, 26 Feb 2010 00:29:05 -0800, Nick Keighley wrote:
>
>>>> particularly if the coder's tools do things such as switching tabs to
>>>> spaces or re-organizing braces, etc, etc, etc, which many tools do.
>>
>> I think your tools are broken
>
> Why?
>
> I happen to feel most comfortable working in a specific manner. Tabs are
> tabs, three columns wide. Braces belong on the next line, under the
> "for" or whatever they're tied to. A blank separating various things
> which should be separated, but only one, and not needlessly. Etc, etc,
> etc.
>
> It's my preferred style, using it keeps me focussed on the problem
> instead of figuring out where the other guy's (to me) brain-dead style
> has left the thrice-damned open brace, particularly if he's using the
> likewise thrice-damned "spaces, not tabs" so popular with some folks but
> which plays merry hob with any editor capable of actually handling tabs
> (i.e. anything written in the last 20 years).

Trouble with tabs is, what is a tab? I use the tab key but my editor
(TextWrangler) just converts them to spaces. Why should spaces bother an
editor, anyway?

--
Tim

"That the freedom of speech and debates or proceedings in Parliament
ought not to be impeached or questioned in any court or place out of
Parliament"

Bill of Rights 1689
From: Tim Woodall on
On Thu, 25 Feb 2010 06:37:18 -0800 (PST),
Anand Hariharan <mailto.anand.hariharan(a)gmail.com> wrote:
> On Feb 24, 4:09�pm, sc...(a)slp53.sl.home (Scott Lurndal) wrote:
>>
>> � �if (condition) {
>>
>> is preferred over
>>
>> � �if (condition)
>> � �{
>>
>> Makes it much more likely that a properly written function will fit on a single
>> page/screen.
>>
>> In 30 years of C programming, no employer or project has used the latter form.
>>
>> scott
>
>
> You've gotten some strong reactions to your not-seen-in-30-years
> comment above.
>
> FWIW I use the latter form myself. However, one good reason I got
> from an ex-colleague for using the first style was that if you are
> scrolling upward in source code, and get to the closing brace of a
> block, using the keyboard shortcut in your editor for jumping to the
> matching brace will get you to see the if (or while or for)
> condition. Otherwise, it will only scroll upward to a point where the
> opening brace is shown as the first line, and one has to go up one
> line more. To me, this is not a big inconvenience.
>
However, the converse is that when cursoring down the code you have to:

a) watch the RH edge of the code for the brace and watch for when the
cursor is on the same line but in column 1 - this is especially true if
you've just bounced to a '}' previously because, at least in vim, you
then lose the "end of line" behaviour of the cursor and it retains the
column position.

b) At least for vim you have to then do $ to get to the end of the line
before you hit the % to find the matching close brace.

if(x<0) {
}
Hitting % while in column 1 of the if line in vim bounces you between
the '(' and ')'

if(x<0)
{
}
Hitting % while in column 1 (or any column) of the line with '{' bounces
you to the '}'

c) Assuming the code is correctly indented - starting with your cursor
on the '{' and then moving downwards you will have read the entire block
when the cursor first stops on a '}' (Assuming your cursor isn't
following the end of the line)

d) For people who persist on using long lines, putting the '{' on a line
on its own will mean it is not off the edge of the screen and invisible
or wrapped onto the next line

Obviously, the major advantage to putting the '{' on the same line as
the conditional is that it reduces paper usage when typesetting and
hence why you will normally see it in books.

Tim.



--
God said, "div D = rho, div B = 0, curl E = - @B/@t, curl H = J + @D/@t,"
and there was light.

http://www.woodall.me.uk/
From: Richard Heathfield on
Tim Streater wrote:
<snip>

> Trouble with tabs is, what is a tab?

A quick way of inserting exactly two spaces into the source.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
From: Tim Streater on
On 26/02/2010 14:51, Richard Heathfield wrote:
> Tim Streater wrote:
> <snip>
>
>> Trouble with tabs is, what is a tab?
>
> A quick way of inserting exactly two spaces into the source.

Since I don't know what tab setting you had when you handed me the code,
I think s/exactly two/a random number of/ applies here.

--
Tim

"That the freedom of speech and debates or proceedings in Parliament
ought not to be impeached or questioned in any court or place out of
Parliament"

Bill of Rights 1689
From: Richard Heathfield on
Tim Streater wrote:
> On 26/02/2010 14:51, Richard Heathfield wrote:
>> Tim Streater wrote:
>> <snip>
>>
>>> Trouble with tabs is, what is a tab?
>>
>> A quick way of inserting exactly two spaces into the source.
>
> Since I don't know what tab setting you had when you handed me the code,

It doesn't matter, since all you get is spaces. (Well, hopefully you get
some code in between the white spaces, too...)

> I think s/exactly two/a random number of/ applies here.

No, exactly two. Always. It's the One True Tab Size. And if you
disagree, obviously you're not a real Scotsman.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
First  |  Prev  |  Next  |  Last
Pages: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Prev: integer
Next: shared memory question