DOS, UNIX and tabs

S

Sebastian 'lunar' Wiesner

Marc 'BlackJack' Rintsch said:
This is a religious issue

It is, because god itself used four spaces for indentation when he wrote
his "world" project in seven days ;)
 
T

Tom Plunket

Steven said:
I don't know what "problems" with tabs you are talking about. I never have
problems with tabs. *Other people* who choose to use software that doesn't
understand tabs have problems.

I've spent a lot of time reading both sides of the tabs versus spaces
argument, and I haven't found anything yet that explains why tabs are, in
and of themselves, bad.

Indeed. In fact, I came to the conclusion several years ago that tabs
are in better for formatting code because then different people on the
team can have their preferred tabstop width, be it 8, 4, or 2 spaces.
Ironically, it has always seemed to me then that tabs are superior for
python editing, since mixing tabs and spaces in an environment like this
means that stuff won't run, whereas in C it'll still compile even if the
code looks awful.


-tom!

--
 
P

Paul McNett

Steven said:
But I think we all agree that mixing tabs and spaces is A Very Bad Thing.

I like mixing tabs and spaces, actually. Tabs for indentation, and
additional spaces to make the code "look pretty". Somebody please tell
me why this is bad and I'll stop.

class Apple(object):
def contrived_example_function(self, argument1, argument2,
argument3, argument4):
print "hello, world"

Apparently, emacs in python mode follows this convention, too. I like it
because I get the best of both worlds: the only thing against using
tabs-only-indentation is that wrapping long lines can be quite ugly,
while space-only-indentation allows for beautifying it somewhat by
lining up the columns to match. Tabs+spaces allows the "lining up" with
spaces to be explicitly separate from indentation.
 
S

Sebastian 'lunar' Wiesner

Paul McNett said:
I like mixing tabs and spaces, actually. Tabs for indentation, and
additional spaces to make the code "look pretty". Somebody please tell
me why this is bad and I'll stop.

class Apple(object):
def contrived_example_function(self, argument1, argument2,
argument3, argument4):
print "hello, world"

Apparently, emacs in python mode follows this convention, too.

That doesn't seem like a standard settings to me. I can't remember
changing the indentation settings for python, nonetheless my gnu emacs
uses four spaces for indentation. Placing wrapped lines into ordered
columns is done by inserting additional spaces. This all happens
automatically; you never need to insert spaces manually...
I like it because I get the best of both worlds: the only thing
against using tabs-only-indentation is that wrapping long lines can be
quite ugly, while space-only-indentation allows for beautifying it
somewhat by lining up the columns to match.

Did you try to open your code files with another editor, which has a
different length for tabulator chars? It would look quite ugly, I
guess...
 
P

Paul McNett

Sebastian said:
That doesn't seem like a standard settings to me. I can't remember
changing the indentation settings for python, nonetheless my gnu emacs
uses four spaces for indentation. Placing wrapped lines into ordered
columns is done by inserting additional spaces. This all happens
automatically; you never need to insert spaces manually...

I never tried emacs, but somebody once told me that if you have set
indentation-by-tab, it will indent with tabs but insert additional
spaces in wrapped lines to look pretty.

Did you try to open your code files with another editor, which has a
different length for tabulator chars? It would look quite ugly, I
guess...

Actually, no. Everyone can choose their own number of spaces-per-tab and
it'll look right, as long as everyone uses a monospace font.
 
M

Marc 'BlackJack' Rintsch

Paul McNett said:
Actually, no. Everyone can choose their own number of spaces-per-tab and
it'll look right, as long as everyone uses a monospace font.

You never tried that with tabs plus additional spaces to line up e.g.
arguments that are broken across lines, right?

And there are a number of environments where you can't change the length
of a tab like email or terminals where code will be displayed from time to
time for example as diffs from a version control system.

Ciao,
Marc 'BlackJack' Rintsch
 
L

Lawrence D'Oliveiro

Marc 'BlackJack' said:
You never tried that with tabs plus additional spaces to line up e.g.
arguments that are broken across lines, right?

I prefer a more two-dimensional layout, keeping consistent indentation. To
illustrate using the example from Paul McNett:

class Apple(object):
        def contrived_example_function \
(
self,
argument1,
argument2,
argument3,
argument4
) :
            print "hello, world"
#end contrived_example_function
#end Apple
 
T

Tom Plunket

Marc said:
You never tried that with tabs plus additional spaces to line up e.g.
arguments that are broken across lines, right?

You must not understand what they're talking about, because it works
fine.

The example is this:

"""\
class Foo:
\tdef Function():
\t\tAnotherFunctionThatTakesManyArguments(arg1,
\t\t arg2,
\t\t arg3)
"""
And there are a number of environments where you can't change the length
of a tab like email or terminals where code will be displayed from time to
time for example as diffs from a version control system.

That's the point of doing it in this way with tabs to specify indent
level and spaces to specify tabular alignment.

Me, I could never get emacs's python stuff to work suitably so I just
use a Dead Simple Editor (SciTE) in which I use tabs exclusively;
continuation indents are always exactly one additional tab over the
thing that's being continued.

Perhaps interestingly, for development I have my editor set to show tabs
as fairly short, but my diff program shows them as eight characters. I
find that makes indentation changes easier to spot in the diffs.


-tom!

--
 
L

Lawrence D'Oliveiro

Perhaps interestingly, for development I have my editor set to show tabs
as fairly short, but my diff program shows them as eight characters. I
find that makes indentation changes easier to spot in the diffs.

I think there should be a single environment variable, perhaps
called "TABS", which specifies the tab settings across all relevant tools
that work with text, including less and diff. So for example setting this
as

export TABS=4

will cause these tools to treat tabs as equivalent to stepping to the next
multiple of four columns from the start of the line.
 
T

Tom Plunket

Lawrence said:
I think there should be a single environment variable, perhaps
called "TABS", which specifies the tab settings across all relevant tools
that work with text, including less and diff. So for example setting this
as

export TABS=4

will cause these tools to treat tabs as equivalent to stepping to the next
multiple of four columns from the start of the line.

Maybe I'm also weird, but I use a variable-pitch font when programming
in Python. So a "tab equals some number of spaces" really isn't useful
to me. My setup is, "tab equals this much space".


-tom!

--
 
P

Peter Decker

Maybe I'm also weird, but I use a variable-pitch font when programming
in Python. So a "tab equals some number of spaces" really isn't useful
to me. My setup is, "tab equals this much space".

A year ago I would have thought you were weird, but after reading a
post by Ed Leafe, one of the creators of Dabo about using proportional
fonts for readability, I thought I'd try it out, thinking that it was
pretty wacky. Turns out that after a very brief adjustment period, I
liked it! I've been using proportional fonts ever since, and have
found only one drawback: code that is indented with spaces looks
butt-ugly. I'm glad I switched to tabs for my code.
 
N

Neil Cerutti

A year ago I would have thought you were weird, but after
reading a post by Ed Leafe, one of the creators of Dabo about
using proportional fonts for readability, I thought I'd try it
out, thinking that it was pretty wacky. Turns out that after a
very brief adjustment period, I liked it! I've been using
proportional fonts ever since, and have found only one
drawback: code that is indented with spaces looks butt-ugly.
I'm glad I switched to tabs for my code.

I first came accross it in Stroustrup's _The C++ Programming
Language_. I liked the look and the idea immediately, but my
editor of choice (by historical accident) Vim, doesn't yet
support it.
 
T

Tom Plunket

Peter said:
A year ago I would have thought you were weird, but after reading a
post by Ed Leafe, one of the creators of Dabo about using proportional
fonts for readability, I thought I'd try it out, thinking that it was
pretty wacky. Turns out that after a very brief adjustment period, I
liked it!

Yep, I had a similar experience although a bit more forced. The editor
that I was using was configured out-of-the-box with variable-pitch, and
I didn't want to bother figuring out how to change it for the quickie
stuff I was writing, then eventually I found that it no longer bothered
me...


-tom!

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top