digitalmars.D.learn - Indenting standards religions K&R, whitesmiths etc
- Cecil Ward (41/41) May 31 2023 I wanted to ask how some of the leaders of our group feel about D
- matheus (22/25) May 31 2023 I don't know nothing about all this but looking your example
- thinkunix (3/31) May 31 2023 +1 here. I think Matheus's code is much easier to read.
- Ernesto Castellotti (4/12) May 31 2023 Excuse me but for me the only style I like is the K&R.
- Cecil Ward (5/18) May 31 2023 Is there even such as thing as a pretty-printer / beautifier for
- Ernesto Castellotti (2/14) May 31 2023 Check this https://github.com/dlang-community/dfmt
- Dukc (21/29) Jun 01 2023 Check out this module from me:
- Cecil Ward (13/43) Jun 01 2023 Agree completely. You are not a criminal though because your
- Cecil Ward (23/53) Jun 01 2023 I wonder how much work it would be to write a D pretty printer /
I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one true brace style’ indenting, with the house style I’m used to being more like whitesmiths. Wikipedia explains this better. Something like the following below. So my question: would I get lynched for the following? (below) And can anyone recommend a beautifier / pretty printer tool for D that is customisable to your house style if that is a thing that’s needed? I assume I would need that if I were to donate code, unless some helpful recipient would run such a tool on .d files received. — pure nothrow etc T foo( T, T2 )( in T param x, in T2 param y ) if ( template-qualification-whatever ) in { static assert( … ); } out ( ret ) { … assert( test ret ); } do { blah if ( test ) { … if-body … } back to main block … … } /* end of function, notice the indent level stays out with the content */
May 31 2023
On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:... So my question: would I get lynched for the following? (below) ...I don't know nothing about all this but looking your example code, I write and I'd prefer to read something like this (Editing your own code): pure nothrow etc T foo(T, T2)(in T param x,in T2 param y) if (template-qualification-whatever) in { static assert(…); } out (ret){ … assert(test ret); }do{ blah if (test) { if-body … } back to main block … … } Matheus.
May 31 2023
matheus via Digitalmars-d-learn wrote:On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:+1 here. I think Matheus's code is much easier to read. Code that is easy to read is easier to understand.... So my question: would I get lynched for the following? (below) ...I don't know nothing about all this but looking your example code, I write and I'd prefer to read something like this (Editing your own code): pure nothrow etc T foo(T, T2)(in T param x,in T2 param y) if (template-qualification-whatever) in { static assert(…); } out (ret){ … assert(test ret); }do{ blah if (test) { if-body … } back to main block … … } Matheus.
May 31 2023
On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one true brace style’ indenting, with the house style I’m used to being more like whitesmiths. Wikipedia explains this better. Something like the following below. [...]Excuse me but for me the only style I like is the K&R. I can accept Allman but the rest is heretical to me ;-) don't worry, just a joke
May 31 2023
On Wednesday, 31 May 2023 at 22:06:50 UTC, Ernesto Castellotti wrote:On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:Is there even such as thing as a pretty-printer / beautifier for D ? Has anyone adapted one ? `it might save me from a lynch mob. :-) :-)I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one true brace style’ indenting, with the house style I’m used to being more like whitesmiths. Wikipedia explains this better. Something like the following below. [...]Excuse me but for me the only style I like is the K&R. I can accept Allman but the rest is heretical to me ;-) don't worry, just a joke
May 31 2023
On Thursday, 1 June 2023 at 03:34:33 UTC, Cecil Ward wrote:On Wednesday, 31 May 2023 at 22:06:50 UTC, Ernesto Castellotti wrote:Check this https://github.com/dlang-community/dfmtOn Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:Is there even such as thing as a pretty-printer / beautifier for D ? Has anyone adapted one ? `it might save me from a lynch mob. :-) :-)[...]Excuse me but for me the only style I like is the K&R. I can accept Allman but the rest is heretical to me ;-) don't worry, just a joke
May 31 2023
On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one true brace style’ indenting, with the house style I’m used to being more like whitesmiths. Wikipedia explains this better. Something like the following below. So my question: would I get lynched for the following? (below)Check out this module from me: https://github.com/dukc/nuklearbrowser/blob/master/source/nuklearbrowser.d Plus similar style in most of my posts and bug reports. I'm still alive :D. Your code is your code. There, you may do as you wish. You have to aknowledge that an esoteric style may make it more difficult to read for some, but we're not lynching people for other factors of code readability either. Brace style is no different. Plus, what brace style is considered readable by the majority is a culture issue. There has to be some way to challege the established culture. If you don't exercise your power to code as you wish, someone will make your choice for you. Coding culture, or even culture in general, cannot develop if people never challege the present status quo. When you're coding with others, though, then you should obey the style guideline of that project if there is one. Even there you're as entitled as anyone for an opinion what the style policy should be (and to whether there should be style policy at all), but you then should (usually) obey the decision regardless whether it's the one you were advocating for.
Jun 01 2023
On Thursday, 1 June 2023 at 09:37:43 UTC, Dukc wrote:On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:Agree completely. You are not a criminal though because your closing braces are not indented out with the block they’re closing as I do. I find K&R hard to read even though we see it everywhere, or variants of it. I do wonder if my style in that earlier post hurts normal people’s eyeballs a lot. ;-) I’m told that Irish speakers can’t understand Scottish Gaelic on the radio a native speaker said to me that ‘it’s just a noise’. But as a ScG learner myself I can understand some spoken Irish even though I’ve never really studied the modern language (only the stuff of more that 1100 yrs ago.) So the pain isn’t symmetrical.I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one true brace style’ indenting, with the house style I’m used to being more like whitesmiths. Wikipedia explains this better. Something like the following below. So my question: would I get lynched for the following? (below)Check out this module from me: https://github.com/dukc/nuklearbrowser/blob/master/source/nuklearbrowser.d Plus similar style in most of my posts and bug reports. I'm still alive :D. Your code is your code. There, you may do as you wish. You have to aknowledge that an esoteric style may make it more difficult to read for some, but we're not lynching people for other factors of code readability either. Brace style is no different. Plus, what brace style is considered readable by the majority is a culture issue. There has to be some way to challege the established culture. If you don't exercise your power to code as you wish, someone will make your choice for you. Coding culture, or even culture in general, cannot develop if people never challege the present status quo. When you're coding with others, though, then you should obey the style guideline of that project if there is one. Even there you're as entitled as anyone for an opinion what the style policy should be (and to whether there should be style policy at all), but you then should (usually) obey the decision regardless whether it's the one you were advocating for.
Jun 01 2023
On Thursday, 1 June 2023 at 09:37:43 UTC, Dukc wrote:On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote:I wonder how much work it would be to write a D pretty printer / beautifier. Doing things such as lining up parameters or comments and breaking and re-wrapping comments etc if necessary because of the changes in whitespace. I’ve no idea what the ‘official story’ is with nested functions. I have some experience with that because I used to write Pascal (on a Z80 box and on a VAX), and that feature is like the return of an old friend, I love it so much and for me it’s quite a serious advantage over C. I’m always guilty of overcommenting, for various reasons although I’m not guilt of the likes of /* add 1 to x */! ;-) It’s partly because I have a shocking memory and maintenance becomes literally impossible for me, for me just as important I want the comments to spell out original intent, not the implementation choices, so if you see later that the two don’t match then you’ve spotted the bug. Many people comment in a very minimal way which makes the code look neat. I did sort of find an /* add 1 to x */ though as it was explaining and giving a caveat about GCC in-line asm constraints, and the comment saved me having to go and look things up in the bible.I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one true brace style’ indenting, with the house style I’m used to being more like whitesmiths. Wikipedia explains this better. Something like the following below. So my question: would I get lynched for the following? (below)Check out this module from me: https://github.com/dukc/nuklearbrowser/blob/master/source/nuklearbrowser.d Plus similar style in most of my posts and bug reports. I'm still alive :D. Your code is your code. There, you may do as you wish. You have to aknowledge that an esoteric style may make it more difficult to read for some, but we're not lynching people for other factors of code readability either. Brace style is no different. Plus, what brace style is considered readable by the majority is a culture issue. There has to be some way to challege the established culture. If you don't exercise your power to code as you wish, someone will make your choice for you. Coding culture, or even culture in general, cannot develop if people never challege the present status quo. When you're coding with others, though, then you should obey the style guideline of that project if there is one. Even there you're as entitled as anyone for an opinion what the style policy should be (and to whether there should be style policy at all), but you then should (usually) obey the decision regardless whether it's the one you were advocating for.
Jun 01 2023