Poll
Choose all styles you can live with, please! (Closed)
1 | 21 | 25% | |
2 | 17 | 20% | |
3 | 39 | 46% | |
4 | 8 | 9% |

int foo (int bar) {
if (1) {
return 2;
} else {
return 3;
}
}
2.
int foo (int bar)
{
if (1) {
return 2;
} else {
return 3;
}
}
3.
int foo (int bar)
{
if (1)
{
return 2;
}
else
{
return 3;
}
}
4.
int foo (int bar)
{
if (1)
{
return 2;
}
else
{
return 3;
}
}
See also http://wiki.openclonk.org/w/User:Isilkor/Style_Guidelines
> See also http://wiki.openclonk.org/w/User:Isilkor/Style_Guidelines
Also please let us know of your concerns or thoughts about the above draft (which only concerns C++ code, not C4Script).

But one question:
You wrote that template casts should be used instead of C-style or function style (C++-Style?) casts.
In my programs I use always 'function' style casts... have the template casts a big advantage?
You get a compiler error if two types are inconvertible and you're using a C++ style cast. If you use C style casts, your program will compile and then probably fail spectacularly at runtime.


And I'm disappointed that the percentages indicate show many of the votes are for an option, not how many of the voters voted for that option. That way we could know whether one option is acceptable by the majority.
The mwf-mulitiple choice polls have never been meaningful as far as I remember.
I would like something like:
int foo (int bar)
{
if (1) {
return 2;
}
else {
return 3;
}
}
That is a rather odd scheme. Is there some code out there that uses it, or is it your invention?

> Could we get an agreement on this?
I'm already using #3 for new code.
> Do you think it would make sense to do an automatic conversion of all engine code?
Last thing I heard there isn't a tool available that gets C++ code right, but I might be mistaken.
[Edit] astyle might do a reasonable job, but I haven't tried.

> Last thing I heard there isn't a tool available that gets C++ code right, but I might be mistaken.
Well, I said I didn't know one, and knew that indent doesn't work, not that there isn't one. Though it's quite possible that nobody has yet written a tool which works for all corner cases C++ offers. And as I don't like style #3, I'm not inclined to waste work on this :-)
I don't think we should use full automatic formatting. Better do some conversion that exactly catches consistent usage of one of the other styles.
After all, there are cases where the indention rules are broken with full intention. I remember doing hundreds of
and still think everything else would be a waste of space.
Maybe I'll code something up. Seems like a fun thing to do with Haskell. Though I'm not really convinced that it's worth it.
After all, there are cases where the indention rules are broken with full intention. I remember doing hundreds of
if(!SomeOperation(...))
{ Log("Error!"); return FALSE; }
and still think everything else would be a waste of space.
Maybe I'll code something up. Seems like a fun thing to do with Haskell. Though I'm not really convinced that it's worth it.


Edit: How does http://github.com/ben0x539/openclonk/commit/braces look to everybody? The engine still runs so I assume everything went well!

My personal opinion on brace style, by the way, is that (a) consistency is good, (b) whitespace-only changes rarely are worth the hassle, thus I'd prefer to only do the minimum amount of changes necessary to achieve constistency, which in the case of the Clonk engine means changing the few places using #3 to #4, (c) lines with only one brace on them are a waste of horizontal space, thus I prefer style #1. This means that I cannot get all my wishes, but I certainly had hoped that I would get at least one...

> As for testing, do a diff of the resulting executable with the previous version. There should only be minor differences if any.
Lots of vaguely differing numbers, not sure what exactly to take away from this. http://ilfirin.org/clonk-disassembled.diff.txt
Also this:
$ for file in `find CMakeFiles -name *.o` ; do diff $file ../openclonk-old/$file ; done
Files CMakeFiles/clonk.dir/src/editor/C4ObjectListDlg.cpp.o and ../openclonk-old/CMakeFiles/clonk.dir/src/editor/C4ObjectListDlg.cpp.o differ
Files CMakeFiles/clonk.dir/src/editor/C4Console.cpp.o and ../openclonk-old/CMakeFiles/clonk.dir/src/editor/C4Console.cpp.o differ


Edit: In as 786734358061
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill