You ( Paavo Helde ) replied ( to me ):
> > 6. Local, ShortTerm variables are nice. Like:
> >
> > wchar _T[999], *P = _T ;
> >
> > Loop(3) { _Loop(4) P += Str( P, L"( %d, %d )%s", J, JJ, J == eJ ? L"\n" : L" " ); }
> >
> > printf( _T );
> >
> > Globals:
> >
> > #define Loop( N ) int eJ = ( N ) - 1, J = -1 ; while ( ++J <= eJ )
> > #define _Loop( N ) int JJ = J, eJ = ( N ) - 1, J = -1 ; while ( ++J <= eJ )
> > #define Str swprintf
> > typedef wchar_t wchar ;
> >
> > Output:
> >
> > ( 0, 0 ) ( 1, 0 ) ( 2, 0 ) ( 3, 0 )
> > ( 0, 1 ) ( 1, 1 ) ( 2, 1 ) ( 3, 1 )
> > ( 0, 2 ) ( 1, 2 ) ( 2, 2 ) ( 3, 2 )
> >
> > See X.CPP in "Jeff-Relf.Me/X.ZIP".
>
> A creative mix of macros and templates makes the code even more
> impenetrable. Your _Loop macros could be probably upgraded to use
> recursive templates instead of boring while cycles, for example!
while() and "Loop(3) { _Loop(4)..." aren't "impenetrable", last I checked.
You ( Paavo Helde ) replied ( to me ):
> > while() and "Loop(3) { _Loop(4)..." aren't "impenetrable", last I checked.
>
> I guess this is something we can disagree on.
>
> _Loop(4) however is just undefined behavior, one is not allowed to use
> such identifiers.
Macros are _good_, you should use them.
Who wouldn't prefer Loop(4) over "for( i=0; I <= 3; i++ )" ?
You must be prejudiced; afraid of change.
> PS. I am currently in the process of refactoring some code from a
> previous coworker who liked macros and templates very much. This task
> has been postponed for 10 years because the code is so intractable. I'm
> pretty sure this coworker thought that he wrote the best code and
> followed the best coding conventions.
Refactoring is good, God's speed.
A complete ReWrite is even better, if you can.
You ( Öö Tiib ) replied ( to me ):
> > while() and "Loop(3) { _Loop(4)..." aren't "impenetrable", last I checked.
>
> Huh? Even name of that _Loop is illegal both by C++ (17.4.3.1.2) and C
> (7.1.3) standards. When noobs use reserved names then behavior of
> program is undefined.
Local definitions override previous ones.
Underscores are too useful to not use.
"Standards" are like assholes, everyone's got one.
You ( Öö Tiib ) replied ( to me ): > > Local definitions override previous ones. > > Underscores are too useful to not use. > > "Standards" are like assholes, everyone's got one. > > I am not sure what standards you're talking about. > I meant the ISO standards of those two languages. I use Visaul Studio 2015, exclusively; so my code conforms to its standards, C++11, C++14 and C++17 ( anticipated ). > Now if you violate the standards as user of compiler then standard- > conforming compiler may (but likely won't) rip you second asshole. _Underscores have never been -- and could never be -- a problem. If I had to rename some variables/funcs/macros, I would, _No _Big _Deal; meanwhile, they're _Useful. Are you _Really worried about compilers "ripping you a new one" ? ! How old are you ? I started coding in _1976, when I was _16. Ever since _1981, it has paid my rent.
You ( Paavo Helde ) replied ( to me ): > > Macros are _good_, you should use them. > > Who wouldn't prefer Loop(4) over "for( i=0; I <= 3; i++ )" ? > > I started to write down a 10-bullet answer for that question, but then I > realized that you must be just trolling as nobody can't be that stupid. Sure, I wrote thousands of lines of C++, just to troll you; to wit: http://Jeff-Relf.Me/cStyle.HTM <Screenshot> > > You must be prejudiced; afraid of change. > > I have changed away from C and macro madness > and have no plans to go back, thank you. From C to what, PHP ? My professional C++ code gets input from, and outputs to Excel 2016. PHP could use #define, seriously.
You ( Jon Kalb ) replied ( to me ):
> > My C++ Coding Standards ( apologies to Bjarne Stroustrup ):
>
> I'm really happy that writing code this way
> has put food on your table since 1981.
It pays my rent; -- food is free for the asking.
Here in Seattle, by the University of Washington, rent is pricey.
> My guess is that, since you happen to be exactly my age,
> it is too late for you to learn "new tricks" so you'll almost certainly
> just run out the clock on your career writing code like this.
Yes because it has, and continues be, the best way.
I'd refine it, if you could offer something better;
sadly, you can't.
> never ask me to review, or work with, code you've written.
I'm a big boy, I don't need your charity.
Note: WhenAndOnlyWhen debugging,
does lots of comments and WhiteSpace make sense.
> never share your coding standards, or other coding advise,
> with anyone else in the C++ community. Ever.
Your request has been denied, silly boy.
You could/should learn from this:
My C++ Coding Style
http://Jeff-Relf.Me/cStyle.HTM
You ( Paavo Helde ) replied ( to me ): > > My professional C++ code gets input from, and outputs to Excel 2016. > > What C++ code? What you have posted online so far is bad C, > with fixed size arrays and unsafe sprintf() variants. Life isn't safe; the more you do, the less safe it is. C++ has #define; use it.
You ( Paavo Helde ) replied ( to me ): > > _Underscores have never been -- and could never be -- a problem. > > If I had to rename some variables/funcs/macros, I would, > > _No _Big _Deal; meanwhile, they're _Useful. > > It took me half a day to figure out why the code stopped _compiling > after adding an innocent #include <string> line, > with mysterious error messages from deep inside system headers. > > It came out that somebody had defined a macro named _B > in some header included by a header included by a header. Compiling C++ is trivial, always. Testing your code can be problematic, sure; but _not compiling, _never. As I said ( in " http://Jeff-Relf.Me/cStyle.HTM " ): Put everything in a single, large .CPP file; -- don't create .H files.
You ( Paavo Helde ) replied ( to me ): > > Compiling C++ is trivial, always. > > Testing your code can be problematic, sure; > > but _not compiling, _never. > > I am pretty sure you are the first one coming up with such > a claim in this group. We should give you a medal or something. I'm just relating my experience ( 40+ years ), that's all. > > Put everything in a single, large .CPP file; > > -- don't create .H files. > > And with what editor I would edit that million-line file? > At least I would have lots of free days when the next one-line > change is compiling ;-) My 2 MegaByte .CPP files compile in no time. How big are yours ( in MegaBytes, not lines ) ? I'm running an i7-5775c with a TeraBye SSD. 16 gigs of 1.9 gigaHz RAM. ArmMounted 4k IPS monitor.
You ( Öö Tiib ) replied ( to me ): > > I use Visaul Studio 2015, exclusively; > > so my code conforms to its standards, > > C++11, C++14 and C++17 ( anticipated ). > > Playing daff? I keep telling you that _Loop is reserved name > that programmers should not use by every of these standards. _Loop() works fine; I don't use "concurrent_vector.h"; even if I did, my local definition OverRides it. I could change the name, of course. I don't create .H files. > > Are you _Really worried about compilers "ripping you a new one" ? ! > > Can't you read? I wrote that those likely won't manifest. Only > sometimes waste time pointlessly. Why to make such defects knowingly? Sorry, but I only see the upside ( readablity ). There are tons of macros/funcs/vars from outside libraries; OverRiding them ( with local definitions ) does happen, rarely, but it has little to do with underscores.
Speaking of me, You ( Brian Wood ) wrote: > I considered his "Loop" macros and searched through > my code for places where I could use something like that. > I only found a handful of places. I don't plan on using that. True, it's not used often; but it's a quicker to type " Loop(4) " than " for ( i = 0; I <= 3; i++ ) ". Modifying a large block of text is another trick I use. Output: When I slept ( 111 rows, 232 columns ) ScreenShot. From X.CPP in " http://Jeff-Relf.Me/X.ZIP ": // Warning: these lines are _long, 238 columns. void SleepPat() { LnP _Out = L" | Turn\n" L" | \n" L" | 1 AM\n" L" | \n" L" | 2 \n" L" | \n" L" | 3 \n" L" | \n" L" | 4 \n" L" | \n" L" | 5 \n" L" | \n" L" | 6 \n" L" | \n" L" | 7 \n" L" | \n" L" | 8 \n" L" | \n" L" | 9 \n" L" | \n" L" | 10 \n" L" | \n" L" | 11 \n" L" | \n" L"................................................................................................................................................................................................................................. | Noon\n" L" | \n" L" | 1 PM\n" L" | \n" L" | 2 \n" L" | \n" L" | 3 \n" L" | \n" L" | 4 \n" L" | \n" L" | 5 \n" L" | \n" L" | 6 \n" L" | \n" L" | 7 \n" L" | \n" L" | 8 \n" L" | \n" L" | 9 \n" L" | \n" L" | 10 \n" L" | \n" L" | 11 \n" L" | \n" L"-------------------------------------------------------------------------- Xxx 5, 2:43 P, 2015 --> Yyy 9, 6: 9 A, 2016 -------------------------------------------------------------------------------------------------- | \n" L" \n" L" \n" L" \n" L" \n" L" \n" L" | Turn\n" L" | \n" L" | 1 AM\n" L" | \n" L" | 2 \n" L" | \n" L" | 3 \n" L" | \n" L" | 4 \n" L" | \n" L" | 5 \n" L" | \n" L" | 6 \n" L" | \n" L" | 7 \n" L" | \n" L" | 8 \n" L" | \n" L" | 9 \n" L" | \n" L" | 10 \n" L" | \n" L" | 11 \n" L" | \n" L"................................................................................................................................................................................................................................. | Noon\n" L" | \n" L" | 1 PM\n" L" | \n" L" | 2 \n" L" | \n" L" | 3 \n" L" | \n" L" | 4 \n" L" | \n" L" | 5 \n" L" | \n" L" | 6 \n" L" | \n" L" | 7 \n" L" | \n" L" | 8 \n" L" | \n" L" | 9 \n" L" | \n" L" | 10 \n" L" | \n" L" | 11 \n" L" | \n" L"-------------------------------------------------------------------------- --> -------------------------------------------------------------------------------------------------- | \n" L" \n" L" \n" L" \n" L" \n" ; const int DateB = 75, DateE = 104, Rows = 48, TopLns = 54, LnLen = 233, Cols = LnLen - 9, Hrs = 48, Turn = 0 * 2 ; wchar Hex ; int Top, Bot, Dur, DateLine, DateLine2, DateLen, Col, Col2, Row, H, M ; float fDur ; LnA LL ; LnP FileNam, Date, First, Last, First2, Last2, Tok, Out ; if ( FileNam = L"SleepLog.TXT", Diff_Load = 1, !Load_File( FileNam ) ) { Sh( L"-- Can't read <%s>.", FileNam ); return; } Top = 1, Bot = DateLine = DateLine2 = 0, Col = Col2 = Cols, Out = _B_Sh, strCpy( Out, _Out ), First = _T, Last = _T + 88, First2 = _T + 200, Last2 = _T + 288, *Last = 0, *Last2 = 0 ; { LoopXx( Ln, fpLines ) { if ( LL = PP + 3, LL >= EE || !Eq( B + 19, L"offline:" ) ) continue; B = *LL, Date = B += 12 - B[-1]; if ( Top ) strCpy( !*Last ? Last : First, Date ); if ( Bot ) strCpy( !*Last2 ? Last2 : First2, Date ); Date += 4, P = Date += *Date == 32 ; To32; DateLen = P - Date, *P++ = 0, P++ ; To!32; Tok = P ; While( Ch != ':' ); *P++ = 0; H = AtoI( Tok ); To!32; Tok = P ; if ( isDigit( *Tok ) ) { To32; *P++ = 0; } M = AtoI( Tok ); if ( *P == 'P' ) H += 12 ; // strCpy( P, L": 2 P " ); 5: P 6:18 P M = M/15, Row = Turn + 2*H + ( !M ? 0 : M == 3 ? 2 : 1 ), Row %= Hrs ; fDur = AtoF( LL[-1] ), Dur = Round( fDur ), Hex = Dur > 9 ? 'A' + Dur - 10 : '0' + Dur ; if ( Top ) { { Loop( Round( 2*fDur ) + 1 ) Out[ ( Row + J )%Hrs * LnLen + Col ] = Hex ; } wmemmove( Out + ( 49 + DateLine )*LnLen + Col, Date, DateLen ), DateLine++, DateLine %= 4 ; } if ( Bot ) { { Loop( Round( 2*fDur ) + 1 ) Out[ ( ( Row + J )%Hrs + TopLns ) * LnLen + Col2 ] = Hex ; } wmemmove( Out + ( 49 + DateLine2 + TopLns )*LnLen + Col2, Date, DateLen ), DateLine2++, DateLine2 %= 4 ; } if ( Bot && !--Col2 ) break ; if ( Top && !--Col ) Top = 0 ; if ( Col == 40 ) Bot = 1 ; } } if ( !*Last ) { Sh( L"-- <%s> has no SleepLog info.", FileNam ); return; } BoReport ; First[6] = Last[6] = ',', First[7] = Last[7] = 32, First[22] = Last[22] = 0 ; First2[6] = Last2[6] = ',', First2[7] = Last2[7] = 32, First2[22] = Last2[22] = 0 ; wmemmove( Out + Rows*LnLen + DateB, First, 22 ), wmemmove( Out + Rows*LnLen + DateE, Last, 22 ); if ( *Last2 ) wmemmove( Out + ( Rows + TopLns )*LnLen + DateB, First2, 22 ), wmemmove( Out + ( Rows + TopLns )*LnLen + DateE, Last2, 22 ); Sh( L"%s\n%s\n%s", RptHdr, L"'C' (Hex) means my monitor was off for 12 hours, starting at the yAxis time, on the xAxis Date.\n", Out ); if ( SaveReport( L"SleepPat.HTM", Replace ) ) TopReport; }
You ( Paavo Helde ) replied ( to me ): > > My 2 MegaByte .CPP files compile in no time. > > How big are yours ( in MegaBytes, not lines ) ? > > most of your file is a poor reimplementation of standard STL utilities > and could be compressed 20x when rewritten in proper C++. No, it doesn't take much to implement STL-like dynamic arrays. template < typename TyT, typename TyA, typename TyP > TyP & Inc( TyT & Xx, int N ); I prefer my own stuff; easier to modify; to wit: My Diff looks like <This>. [ Red is the old stuff, Green is new ] > As to answer your question, the current source code written > by our group for our product is 33 MB / 748,308 lines. > It recompiles in ca 20 minutes thanks to SSD disks. What does it do ? You could condense it down into fewer, larger, .CPP files; or not... it's up to you and yours, of course.
You ( Andy ) replied ( to me ): > > _Loop() works fine; I don't use "concurrent_vector.h"; > > even if I did, my local definition OverRides it. > > I could change the name, of course. I don't create .H files. > > The point is that _you_ are forbidden to use a name like that. I'm sorry if _you_ can't but I sure as hell can/do. > They are reserved for the compiler, > and the next release of the compiler is quite entitled to > #define it to something that causes really weird errors. My " _Loop( N ) " OverRides that; so no problem. > And please don't post those funny font settings. The "OCR A" font ( Optical Character Recognition ) is best because each glyph is distinct, unique. Mozilla FireFox and ThunderBird add other fonts to it, as needed, depending on the glyph. Personally, I use "OCR A", "MS Mincho", "Segoe UI Symbol", "DejaVu LGC Sans Mono" and "nSimSun" -- all "Console" fonts, MonoSpaced ( some are double wide ). Depends on the glyph. ScreenShot: http://Jeff-Relf.Me/X.PNG
You ( Ian Collins ) replied ( to me ): > > You could condense it down into fewer, larger, .CPP files; > > or not... it's up to you and yours, of course. > > Fewer, larger .cpp files has always been a pain for readers, > on modern multi-core systems it's the best way to ruin build times. For me, compile time is barely noticeable. What are you compiling, and how long does it take ? ! I'm running a Core i7-5775c with a TeraBye SSD. 16 gigs of 1.9 gigaHz RAM. ArmMounted 4k IPS monitor.
You ( Ian Collins ) replied ( to me ): > > For me, compile time is barely noticeable. > > What are you compiling, and how long does it take ? ! > > A large control application along with about 50 other developers. > A single target build takes several minutes on a 32 core machine. What's being controlled, a robot ? What OS are you running on this "32 core machine", and how many people access it ? > Not only would fewer, larger files be a nightmare to edit > and build, we would have way too many _merges to ever get anything done. I can't imagine what it's like to work with "50 other developers", all working on the same bit of code... are you Linus Torvalds ?
You ( Ian Collins ) replied ( to me ): > > What's being controlled, a robot ? > > Heavy machinery. > > > What OS are you running on this "32 core machine", > > and how many people access it ? > > Some Linux, some Windows. > All virtual machines on SmartOS hypervisors. Compile time isn't the bottle neck then because, to run, you have to wait on 50+ people, running various _guest operating systems ( on the _host ), controlling the (slow?) "heavy machinery". Checking code in and out limits the size of the .CPP file, not compile time; whatever the limitations, still: Fewer, Larger, .CPP files are better. > Please stop changing the subject.... The _Default "Subject:" line is neither mandatory or desirable. Quoting " rfc1036: Standard for Interchange of USENET Messages " https://www.w3.org/Protocols/rfc1036/rfc1036.html#z4 << The "Subject" line ( formerly "Title" ) tells what the message is about. It __Should be suggestive enough of the contents of the message to enable a reader to make a decision whether to read the message BASED ON THE SUBJECT ALONE. If the message is submitted in response to another message ( e.g., is a follow-up ) the _Default subject should begin with the four characters "Re:", and the "References" line is required. >> Like it or not, the subject has changed; no longer are we talking about the original post, " Technical challenge for DFS "; -- we're not even in the original NewsGroup. This Thread, from Parent to Child: Incubus│incubus9536612 f55d5858-3f4b-4644...@googlegroups.com JeffRelf Jeff-R...@Dec.17--0.34P.Seattle.2016 MichaelMoroney o394s3$e6h$3...@pcls7.std.com JeffRelf Jeff-R...@Dec.19--10.56A.Seattle.2016 MichaelMoroney o3b89q$nfe$1...@pcls7.std.com JeffRelf Jeff-R...@Dec.20--6.06A.Seattle.2016 MichaelMoroney o3bhcr$d8m$1...@pcls7.std.com JeffRelf Jeff-R...@Dec.20--9.59A.Seattle.2016 MichaelMoroney o3ceg5$9d8$1...@pcls7.std.com JeffRelf Jeff-R...@Dec.20--4.15P.Seattle.2016 MrDFS o3d28c$7c2$1...@dont-email.me JeffRelf Jeff-R...@Dec.21--2.55A.Seattle.2016 MichaelMoroney o3fgrl$6eb$1...@pcls7.std.com JeffRelf Jeff-R...@Dec.22--2.36A.Seattle.2016 MichaelMoroney o3hg73$k8h$1...@pcls7.std.com MrChrisV jtaq5cd44la7u24la...@4ax.com flatfish+++│flatfish ec4r1j...@mid.individual.net MichaelMoroney o3jiu8$v4p$2...@pcls7.std.com JeffRelf Jeff-R...@Dec.23--8.52A.Seattle.2016 MichaelMoroney o3jsu7$he6$1...@pcls7.std.com MrChrisV mbuq5cpls71t5eoq0...@4ax.com PeterKöhlmann o3jveq$ll6$2...@dont-email.me MichaelGlasser D482D7F6.85EDE%use...@gallopinginsanity.com PeterKöhlmann o3k5gr$c3c$1...@dont-email.me JeffRelf Jeff-R...@Dec.23--5.06P.Seattle.2016 Paavo_Helde│myfirstname@osa_ i5Wdne2lmpeKpMPF...@giganews.com JeffRelf Jeff-R...@Dec.26--0.36P.Seattle.2016 Öö_Tiib│ootiib@hotΞee c9d1a189-8c1f-45ef...@googlegroups.com JeffRelf Jeff-R...@Dec.26--1.54P.Seattle.2016 Öö_Tiib│ootiib@hotΞee 63c6380a-a9cb-488a...@googlegroups.com JeffRelf Jeff-R...@Dec.26--5.31P.Seattle.2016 Paavo_Helde│myfirstname@osa_ M5mdnYP0JMYQ0v_F...@giganews.com JeffRelf Jeff-R...@Dec.27--10.56A.Seattle.2016 Paavo_Helde│myfirstname@osa_ KrydnZ4Ez9e-Xv_F...@giganews.com JeffRelf Jeff-R...@Dec.27--11.56A.Seattle.2016 Paavo_Helde│myfirstname@osa_ _u-dnbF6oopsef_F...@giganews.com JeffRelf Jeff-R...@Dec.27--4.16P.Seattle.2016 Ian_Collins│ian-news ecghqg...@mid.individual.net JeffRelf Jeff-R...@Dec.27--5.22P.Seattle.2016 Ian_Collins│ian-news ecgmls...@mid.individual.net JeffRelf Jeff-R...@Dec.27--6.53P.Seattle.2016 Ian_Collins│ian-news ecgp03...@mid.individual.net
You ( Ian Collins ) replied ( to me ): > > Checking code in and out limits the size of the .CPP file, > > not compile time; whatever the limitations, still: > > Fewer, Larger, .CPP files are better. > > Nope, build times are the bottleneck. If there were larger files, there > would be less build distribution, some files would need too much memory > to optimise, developers would waste too much time merging changes and > they would get pissed off editing the large files. You _say that neither your programmers nor your compilers could handle fewer, larger .CPP files but you could be wrong. Have you tried fewer, larger .CPP files ? Would a hardware/software upgrade help ? Are you running legacy hardware/software ?
You ( Öö Tiib ) replied ( to me ): > > Sorry, but I only see the upside ( readablity ). > > > > There are tons of macros/funcs/vars from outside libraries; > > OverRiding them ( with local definitions ) does happen, rarely, > > but it has little to do with underscores. > > Where is that readability? Your words lack logic. One who sees > that _Loop in code most likely thinks that it is some compiler-specific > keyword (like _Bool or _Complex of C). Later it occurs that it is just > other guy misusing reserved naming convention for his own custom > code-mutating macro. So it was confusing. "Confusing" is not synonym > of "readable". > > If you write code that confuses others then it makes it hard to cooperate > with you. That is bad since most software is not written alone. What I > have typically seen are up to 10 teams of 4 to 8 persons per team. UnderScores or Not, one must check for local OverRides. Search the .CPP file, to see if it's defined locally ( it is ).
You ( Ian Collins ) replied ( to me ): > > Have you tried fewer, larger .CPP files ? > > No, for the simple reasons stated above. > > > Would a hardware/software upgrade help ? > > Faster hardware always helps.... > We current have the fastest available. Sadly, I've failed to merge some of my .CPP files/apps because the required testing would be too expensive/painful; as a result, they're not as fresh/tested as they could be.
You ( interval1066 ) replied ( to me ): > > Macros are _good_, you should use them. > > Sure. Microsoft created a whole language out of them. Its called MFC. True that, MFC sucks. _My Macros are good ( for me, and only me ). P.S. I improved the look of my Source Code Comparison routine. ScreenShot:![]()
You ( Vir Campestris ) replied ( to Michael Moroney ): > > Gee, the code from the forged Relf looks better than > > the code from the real Jeff. > > FFS - HE's got a stalker??? I have an AntiFanBoy, from time to time.