Not logged inOpenClonk Forum
Poll Choose all styles you can live with, please! (Closed)
1 21 25%
2 17 20%
3 39 46%
4 8 9%
- - By Günther [de] Date 2009-08-13 22:35 Edited 2009-08-13 22:37
1.
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
Reply
Parent - - By Caesar [de] Date 2009-08-14 00:08
Is it about the scripts or about new C++-code?
Parent - - By Günther [de] Date 2009-08-14 00:25
C++. The Script already has a consistent style.
Reply
Parent - By Ringwaul [ca] Date 2009-08-14 03:21
Whoops. I suppose I shouldn't have voted in that case.
Reply
Parent - - By Isilkor Date 2009-08-14 00:57

> 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).
Reply
Parent - - By henry [de] Date 2009-08-18 13:16
Good job Isilkor. I like guidelines and conventions. :D

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?
Parent - - By Isilkor Date 2009-08-18 16:18
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.
Reply
Parent - By henry [de] Date 2009-08-25 09:44
You mean, when I'am using a template cast?
Okay, that is convincing. :)
Parent - By Newton [es] Date 2009-08-14 15:23
I just broke the habit of scripting in 1 to code in 3 but to all except 4 I can adjust.
Parent - - By Günther [de] Date 2009-08-14 18:37 Edited 2009-08-14 18:41
Hm. The popularity of #3 at least somewhat explains why it keeps on creeping into the engine source code despite #4 being used in the vast majority of source files.

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.
Reply
Parent - - By Caesar [de] Date 2009-08-15 10:36
The mwf-mulitiple choice polls have never been meaningful as far as I remember.
Parent - By Günther [de] Date 2009-08-15 11:47
Oh, the results are meaningful enough. Knowing the number of participants is not essential, only nice-to-have.
Reply
Parent - - By Günther [de] Date 2009-08-15 11:48
So who's gonna change the engine code away from #4?
Reply
Parent - - By Isilkor Date 2009-08-15 14:49
indent(1)? ;-)
Reply
Parent - By Günther [de] Date 2009-08-15 16:15
Doesn't work for C++. And if you have a tool which does, you still need to check the output.
Reply
Parent - - By Atomclonk [de] Date 2009-08-17 14:50 Edited 2009-08-17 16:48
I would like something like:

int foo (int bar)
{
if (1) {
  return 2;
  }
else {
  return 3;
  }
}
Reply
Parent - - By Isilkor Date 2009-08-17 16:49
That is a rather odd scheme. Is there some code out there that uses it, or is it your invention?
Reply
Parent - - By Atomclonk [de] Date 2009-08-17 18:47
uh... mostly seen in C4Scripts, then used it by myself.
Reply
Parent - - By Newton [es] Date 2009-08-17 18:50
uhucode?
Parent - By Atomclonk [de] Date 2009-08-17 18:50
Who knows .
Reply
Parent - - By henry [de] Date 2009-08-18 13:17
O_o
Parent - - By Luchs [de] Date 2009-08-18 13:44
Ever read through the InExantros-Code? (http://forum.clonk2c.ch/topic_show.pl?pid=15998#pid15998 <- !)
Parent - By henry [de] Date 2009-08-18 13:56
:D
Parent - - By B_E [de] Date 2009-08-17 16:55
Pearsyntax ftw.
Parent - - By Isilkor Date 2009-08-17 17:35
For the record: "Pearsyntax" seems to be style No. 2.
Reply
Parent - By B_E [de] Date 2009-08-17 21:58
Yes, I should have made myself clearer ;)
Parent - - By Sven2 [de] Date 2009-10-13 20:07
Since #3 is the most popular one, I will switch to it now for new code. Could we get an agreement on this? Do you think it would make sense to do an automatic conversion of all engine code? (thinking of future branch merging/rebase now)
Parent - - By Isilkor Date 2009-10-13 20:41 Edited 2009-10-13 20:49

> 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.
Reply
Parent - By Günther [de] Date 2009-10-13 21:13

> 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 :-)
Reply
Parent - By PeterW [de] Date 2009-10-13 23:24 Edited 2009-10-13 23:30
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

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.
Parent - - By Kanibal [de] Date 2009-10-14 14:09
The eclipse-IDE could do that...
Reply
Parent - - By Isilkor Date 2009-10-14 15:14
Unless it has batch processing, that's probably quite a tedious task.
Reply
Parent - By Kanibal [de] Date 2009-10-14 15:44
Nope, it isn't. You can select all your source files and then let it run.
Reply
Parent - - By Günther [de] Date 2010-03-26 20:37
If nobody volunteers to change the engine in this regard, I'll declare style #4 as the winner, simply because it's used by the majority of the engine source code and I can live with it. I'm also volunteering to change the few places using #3 to #4.
Reply
Parent - - By Loriel Date 2010-03-26 22:26 Edited 2010-03-26 23:09
I will volunteer to try to use indent or something to get everything to conform to option #1, if that helps.

Edit: How does http://github.com/ben0x539/openclonk/commit/braces look to everybody? The engine still runs so I assume everything went well!
Parent - - By Zapper [de] Date 2010-03-26 22:32
Or to the winner, option 3? :<
Parent - By Loriel Date 2010-03-26 22:37
Guenther just had to list the options in order of how much I like them, I never read beyond #1.
Parent - - By Günther [de] Date 2010-03-27 00:23 Edited 2010-03-27 00:33
No way, Indentation must be done with tabs. As for testing, do a diff of the resulting executable with the previous version. There should only be minor differences if any.

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...
Reply
Parent - By Loriel Date 2010-03-27 16:19

> 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
Parent - - By Caesar [de] Date 2010-03-27 15:43
Why did you start this poll then?
Parent - - By Günther [de] Date 2010-03-27 16:18
I had hoped that either one of my favorite options would win, or that somebody else would do the work to convert the engine to the winning style. That's not an unreasonable hope, and if nobody cares enough to do the work, they can't complain if their favorite choice isn't used.
Parent - By Loriel Date 2010-03-27 16:30 Edited 2010-03-28 20:18
http://github.com/ben0x539/openclonk/commit/allman should be reasonably close to the winning style, I suppose.

Edit: In as 786734358061

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill