By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,638 Members | 2,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,638 IT Pros & Developers. It's quick & easy.

folds and formatting

P: n/a

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.

Apr 13 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

Bill Pursell wrote:
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.

Apr 13 '06 #2

P: n/a
On 13 Apr 2006 13:43:08 -0700, "Bill Pursell" <bi**********@gmail.com>
wrote:

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.
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.


--
Al Balmer
Sun City, AZ
Apr 13 '06 #3

P: n/a
Bill Pursell wrote:
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.

Apr 14 '06 #4

P: n/a
"sl*******@yahoo.com" <sl*******@gmail.com> writes:
Bill Pursell wrote:
int
foo(void)
{
/** Brief explanation of foo.*/
...
}


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.
--
"What is appropriate for the master is not appropriate for the novice.
You must understand the Tao before transcending structure."
--The Tao of Programming
Apr 14 '06 #5

P: n/a
On Fri, 14 Apr 2006 08:05:20 -0700, Ben Pfaff <bl*@cs.stanford.edu>
wrote:
"sl*******@yahoo.com" <sl*******@gmail.com> writes:
Bill Pursell wrote:
int
foo(void)
{
/** Brief explanation of foo.*/
...
}


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.


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.

--
Al Balmer
Sun City, AZ
Apr 14 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.