home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 263,066 of 264,096   
   Dan Cross to news@cct-net.co.uk   
   Re: extending MySQL on VMS   
   20 Aug 25 18:08:10   
   
   From: cross@spitfire.i.gajendra.net   
      
   In article <1084v8t$95kl$2@dont-email.me>,   
   Chris Townley   wrote:   
   >On 20/08/2025 13:27, Simon Clubley wrote:   
   >> Indented properly (not as in your next example!) I find that   
   >very   
   >> readable and is mostly how I would write it although I do use code   
   >> like your return example when appropriate. This is my variant:   
   >>   
   >> 	if (p != NULL)   
   >> 		{   
   >> 		if (p->ptr != NULL)   
   >> 			{   
   >> 			if (something(*p->ptr))   
   >> 				{   
   >> 				// Do something....   
   >> 				}   
   >> 			}   
   >> 		}   
   >>   
   >> In case that doesn't survive a NNTP client, it is in Whitesmiths format:   
   >   
   >   
   >That is why I don't like Whitesmiths   
   >   
   >To me the curly braces should logically align with the preceding statement.   
   >   
   >When I first looked at he example, I immediately thought there is a   
   >missing closing brace, which of course there isn't.   
      
   Just give yourself over to a tool to manage formatting.  It   
   won't feel "perfect", certainly not at first, but in a very   
   short time it will become indispensible.   
      
   https://clang.llvm.org/docs/ClangFormat.html   
      
   >I also dislike putting the opening brace at the end of the preceding   
   >line, although I have had to in some cases. Probably a Microsoft invention   
      
   As in,   
      
       if (foo != 2) {   
   	/* whatever here... */   
       }   
      
   ?   
      
   That demonstrably predates Microsoft.  It's often called K&R   
   style, or sometimes, the "One True Brace Style", because it was   
   used in Kernighan and Ritchie's books on C; Ritchie, of course,   
   being the primary architect and earliest implementer of the C   
   language, based on a language called B (and "new B" or nb) by   
   Ken Thompson, which itself was based on Martin Richards's BCPL.   
   This was also the style used in the Unix kernel, which was   
   probably the first really serious program written in C.   
      
   As they put it in the first edition of K&R (1978):   
      
   |Although C is quite permissive about statement positioning,   
   |proper indentation and use of white space are critical in   
   |making programs easy for people to read.  The position of the   
   |braces is less important; we have chosen one of several   
   |popular styles.  Pick a style that suits you, then use it   
   |consistently.   
      
   The intent was good here, but really, they should have just said   
   "use this style" and been done with it.  It'd have saved a lot   
   of blocks on disks storing USENET messages arguing over where to   
   put the braces. :-D   
      
   Btw, some folks may find Henry Spencer's, "10 Commandments for C   
   Programmers" amusing.  Number 8 is relevant here:   
   https://www.lysator.liu.se/c/ten-commandments.html   
      
   	- Dan C.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca