folds and formatting

B

Bill Pursell

For several years now, "folding" has become more and more
common in text editors. That has had an affect on my
commenting style. For example, the appealing layout:

int
foo(void)
{
/** Brief explanation of foo.*/
....
}

has now changed to:
int
foo(void)
{ /** Brief explanation of foo.*/
....
}

I find the second layout ugly, but when you fold based on brackets,
the comment remains visible, while the comment in the first layout
gets hidden in the fold. Similarly,

if (expr) {
/* brief comment*/
statement;
}

Is now more convenient to write with the comment on the line with
the open brace.

I'm curious to know how folding is affecting people's sylistic
conventions.
 
A

Andrew Poelstra

Bill said:
For several years now, "folding" has become more and more
common in text editors. That has had an affect on my
commenting style. For example, the appealing layout:

int
foo(void)
{
/** Brief explanation of foo.*/
...
}

has now changed to:
int
foo(void)
{ /** Brief explanation of foo.*/
...
}

I find the second layout ugly, but when you fold based on brackets,
the comment remains visible, while the comment in the first layout
gets hidden in the fold. Similarly,

if (expr) {
/* brief comment*/
statement;
}

Is now more convenient to write with the comment on the line with
the open brace.

I'm curious to know how folding is affecting people's sylistic
conventions.

I can't really think of where this belongs (perhaps comp.programmer),
so I'll just reply to it instead of complaining about your
offtopicness.

I have always used vi, and continue to do so. All of my folding text
editors (Notepad++ when I'm on Windows) allow me not to fold, and so I
don't. My style remains the same regardless of text editor trends.

Folding is only useful for when you need to scan for functions;
comments explaining the purpose of a function belong above the header,
and so won't be folded anyway.
 
A

Al Balmer

For several years now, "folding" has become more and more
common in text editors. That has had an affect on my
commenting style. For example, the appealing layout:

int
foo(void)
{
/** Brief explanation of foo.*/
...
}

has now changed to:
int
foo(void)
{ /** Brief explanation of foo.*/
...
}

I find the second layout ugly, but when you fold based on brackets,
the comment remains visible, while the comment in the first layout
gets hidden in the fold.

My preferred method is to put the comment above the definition,
unaffected by the folding.
 
S

slebetman

Bill said:
For several years now, "folding" has become more and more
common in text editors. That has had an affect on my
commenting style. For example, the appealing layout:

int
foo(void)
{
/** Brief explanation of foo.*/
...
}

has now changed to:
int
foo(void)
{ /** Brief explanation of foo.*/
...
}

I find both ugly. My preferred convention is:

/** Brief explanation of foo.*/
int foo(void)
{
...
}

I've been doing this since even before I started using a folding editor
so it doesn't affect my style. It's from the good old assembly days to
comment on your intention before the actual code. Besides this
convention is more easily digestable by auto-documenting tools like
doxygen.
 
B

Ben Pfaff

I find both ugly. My preferred convention is:

/** Brief explanation of foo.*/
int foo(void)
{
...
}

I use comments above the function definition (the former style,
roughly) to describe the function's interface, and comments
within the function definition (the latter style, roughly) to
describe the function's implementation.
 
A

Al Balmer

I use comments above the function definition (the former style,
roughly) to describe the function's interface, and comments
within the function definition (the latter style, roughly) to
describe the function's implementation.

I've always done the "above the definition" comments, and find it
especially nice that my editor, if you hover the mouse over a function
name, will pop up the comment block preceding the function definition.
 

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
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top