* Source Code Formatting Standard Update
@ 2009-09-14 19:00 jyqvklioo
2009-09-14 21:42 ` Stefan Monnier
2009-09-16 11:56 ` jyqvklioo
0 siblings, 2 replies; 13+ messages in thread
From: jyqvklioo @ 2009-09-14 19:00 UTC (permalink / raw)
To: emacs-devel
I quote:
"
http://www.gnu.org/prep/standards/html_node/Formatting.html
5.1 Formatting Your Source Code
It is important to put the open-brace that starts the body of a
C function in column one, so that they will start a defun.
"
Does emacs still have this limitation?
If not,
the standard can be updated to make the curly brace placement more consistent.
The next issue is not emacs specific,
but here may be as good a place to address it as there is, as far as I can see.
"
In Standard C, if the arguments don't fit nicely on one line, split it like this:
int
lots_of_args (int an_integer, long a_long, short a_short,
double a_double, float a_float)
"
This practice produces poor results in languages with highly nested namespaces,
like object oriented languages. There you can get code like:
namespace.ClassName.NestedClass.nicelyDescriptiveClassName.staticMethod(namespace.ParameterObject
a,
otherNamespace.secondObject
b);
If you line break at periods also, the names would span multiple lines.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Source Code Formatting Standard Update
2009-09-14 19:00 Source Code Formatting Standard Update jyqvklioo
@ 2009-09-14 21:42 ` Stefan Monnier
2009-09-15 15:12 ` Richard Stallman
2009-09-16 11:56 ` jyqvklioo
1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2009-09-14 21:42 UTC (permalink / raw)
To: jyqvklioo; +Cc: emacs-devel
> "
> http://www.gnu.org/prep/standards/html_node/Formatting.html
> 5.1 Formatting Your Source Code
> It is important to put the open-brace that starts the body of a
> C function in column one, so that they will start a defun.
> "
> Does Emacs still have this limitation?
> If not, the standard can be updated to make the curly brace placement
> more consistent.
AFAIK, the standard was not designed like this because of Emacs's
limitations, but because it was considered a good habit.
I don't think this consideration has changed.
> "
> In Standard C, if the arguments don't fit nicely on one line, split it like this:
> int
> lots_of_args (int an_integer, long a_long, short a_short,
> double a_double, float a_float)
> "
> This practice produces poor results in languages with highly nested
> namespaces, like object oriented languages. There you can get code
> like:
> namespace.ClassName.NestedClass.nicelyDescriptiveClassName.staticMethod(namespace.ParameterObject
> a,
> otherNamespace.secondObject
> b);
Obviously, this is unreadable, so you should write it differently.
But if the alternatives are worse for one reason or another, the right
way to do it is to place a line break after the open-paren.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Source Code Formatting Standard Update
2009-09-14 19:00 Source Code Formatting Standard Update jyqvklioo
2009-09-14 21:42 ` Stefan Monnier
@ 2009-09-16 11:56 ` jyqvklioo
2009-09-16 12:13 ` Alfred M. Szmidt
2009-09-16 13:57 ` Stephen J. Turnbull
1 sibling, 2 replies; 13+ messages in thread
From: jyqvklioo @ 2009-09-16 11:56 UTC (permalink / raw)
To: emacs-devel
So, these days at least, there is no technical motivation for having the open curly brace '{' in column 0. I plea that the Standard be amended so that the { placement for the start of a body of a non-enclosed function is consistent with use otherwise. The increased consistency will also make it possible to have simpler implementations of automatic formatting software.
The other issue I addressed is also one that would simplify implementations of formatters and, in most software implemented in object oriented languages, improve readability.
I prefer to leave formatting source code to a machine; even more so when working in a team. When formatting is not available by automation, it sometimes does not get done. I would like to have a fast, standalone formatter as a pre commit hook to a VCS.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Source Code Formatting Standard Update
2009-09-16 11:56 ` jyqvklioo
@ 2009-09-16 12:13 ` Alfred M. Szmidt
2009-09-16 13:33 ` jyqvklioo
2009-09-16 13:57 ` Stephen J. Turnbull
1 sibling, 1 reply; 13+ messages in thread
From: Alfred M. Szmidt @ 2009-09-16 12:13 UTC (permalink / raw)
To: jyqvklioo; +Cc: emacs-devel
So, these days at least, there is no technical motivation for
having the open curly brace '{' in column 0. I plea that the
Standard be amended so that the { placement for the start of a body
of a non-enclosed function is consistent with use otherwise. The
increased consistency will also make it possible to have simpler
implementations of automatic formatting software.
I'm not sure what you mean, the requirement is only for function
bodies, placing the curly at any other position seems very weird to
me. And it makes it very simple to figure out what is a defun or
isn't, automatically and by the brain.
I prefer to leave formatting source code to a machine; even more so
when working in a team. When formatting is not available by
automation, it sometimes does not get done. I would like to have a
fast, standalone formatter as a pre commit hook to a VCS.
GNU indent does the right thing by default when it comes to the GNU
coding standards. And you can supply switches so that it does the
right thing for your team.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Source Code Formatting Standard Update
2009-09-16 12:13 ` Alfred M. Szmidt
@ 2009-09-16 13:33 ` jyqvklioo
2009-09-16 13:52 ` Alfred M. Szmidt
2009-09-16 14:08 ` Miles Bader
0 siblings, 2 replies; 13+ messages in thread
From: jyqvklioo @ 2009-09-16 13:33 UTC (permalink / raw)
To: emacs-devel
>> The increased consistency will also make it possible to have simpler
>> implementations of automatic formatting software.
>I'm not sure what you mean,
>the requirement is only for function bodies, (...).
I mean to make the requirement for function bodies the same as for other blocks.
To make example code with a loop:
void
functionName()
{
for(unsigned i=0;i<4;i++)
{
doMe(pretendItWrapped here,
andCode continued);
}
}
Each parethesis, brace, or bracket can mean the same increase of indentation
level. Each { indicates a new block and sub-namespace.
For me this is more logical and understandable. I expect it is otherwise for
some people. Being accustomed to a certain practice is usual.
>GNU indent does the right thing by default when it comes to the GNU
>coding standards.
I tried 2 standalone programs previously. 1 of which was "GNU indent". 1 did
not run on a non-unix platform, which at the time was a requirement, but may not
be for other projects. The other was unreliable.
With the alterations I proposed, a hard coded formatter could be simple, speedy,
and reliable: a combination I have not seen despite searching. Even if there
were software available, there could be lighter weight, simpler software to
implement the formatting if each parethesis, brace, or bracket resulted in the
same increase of indentation level.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Source Code Formatting Standard Update
2009-09-16 11:56 ` jyqvklioo
2009-09-16 12:13 ` Alfred M. Szmidt
@ 2009-09-16 13:57 ` Stephen J. Turnbull
1 sibling, 0 replies; 13+ messages in thread
From: Stephen J. Turnbull @ 2009-09-16 13:57 UTC (permalink / raw)
To: jyqvklioo; +Cc: emacs-devel
jyqvklioo@googlemail.com writes:
> I plea that the Standard be amended so that the { placement for the
> start of a body of a non-enclosed function is consistent with use
> otherwise.
-1
No thank you. Good standards are good, bad standards are bad,
changing standards are the worst. There is no strong reason to
change on the table, so let's not.
If you don't like the GNU standard, don't adopt it in your own
projects. At the start of a new cooperative project, argue for what
you consider a more rational standard. However, projects that have
followed it for a long time, including the whole GNU project, should
continue to do so unless a strong technical reason for changing can be
advanced. A little bit of extra work for automatic formatters and
those who write them is not such a reason.
> The increased consistency will also make it possible to have
> simpler implementations of automatic formatting software.
What could be simpler than to just let Emacs do it?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Source Code Formatting Standard Update
@ 2009-09-15 5:53 jyqvklioo
0 siblings, 0 replies; 13+ messages in thread
From: jyqvklioo @ 2009-09-15 5:53 UTC (permalink / raw)
To: emacs-devel
I quote:
"
http://www.gnu.org/prep/standards/html_node/Formatting.html
5.1 Formatting Your Source Code
It is important to put the open-brace that starts the body of a
C function in column one, so that they will start a defun.
"
Does emacs still have this limitation?
If not,
the standard can be updated to make the curly brace placement more consistent.
The next issue is not emacs specific,
but here may be as good a place to address it as there is, as far as I can see.
"
In Standard C, if the arguments don't fit nicely on one line, split it like this:
int
lots_of_args (int an_integer, long a_long, short a_short,
double a_double, float a_float)
"
This practice produces poor results in languages with highly nested namespaces,
like object oriented languages. There you can get code like:
namespace.ClassName.NestedClass.nicelyDescriptiveClassName.staticMethod(namespace.ParameterObject
a,
otherNamespace.secondObject
b);
If you line break at periods also, the names would span multiple lines.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Source Code Formatting Standard Update
@ 2009-09-15 7:31 jyqvklioo
2009-09-15 7:39 ` Alfred M. Szmidt
0 siblings, 1 reply; 13+ messages in thread
From: jyqvklioo @ 2009-09-15 7:31 UTC (permalink / raw)
To: emacs-devel
I quote:
"
http://www.gnu.org/prep/standards/html_node/Formatting.html
5.1 Formatting Your Source Code
It is important to put the open-brace that starts the body of a
C function in column one, so that they will start a defun.
"
Does emacs still have this limitation?
If not,
the standard can be updated to make the curly brace placement more consistent.
The next issue is not emacs specific,
but here may be as good a place to address it as there is, as far as I can see.
"
In Standard C, if the arguments don't fit nicely on one line, split it like this:
int
lots_of_args (int an_integer, long a_long, short a_short,
double a_double, float a_float)
"
This practice produces poor results in languages with highly nested namespaces,
like object oriented languages. There you can get code like:
namespace.ClassName.NestedClass.nicelyDescriptiveClassName.staticMethod(namespace.ParameterObject
a,
otherNamespace.secondObject
b);
If you line break at periods also, the names would span multiple lines.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2009-09-16 14:08 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-14 19:00 Source Code Formatting Standard Update jyqvklioo
2009-09-14 21:42 ` Stefan Monnier
2009-09-15 15:12 ` Richard Stallman
2009-09-16 11:56 ` jyqvklioo
2009-09-16 12:13 ` Alfred M. Szmidt
2009-09-16 13:33 ` jyqvklioo
2009-09-16 13:52 ` Alfred M. Szmidt
2009-09-16 14:08 ` Miles Bader
2009-09-16 13:57 ` Stephen J. Turnbull
-- strict thread matches above, loose matches on Subject: below --
2009-09-15 5:53 jyqvklioo
2009-09-15 7:31 jyqvklioo
2009-09-15 7:39 ` Alfred M. Szmidt
2009-09-15 8:03 ` David Kastrup
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.