From: already5chosen@yahoo.com   
      
   On Fri, 10 Oct 2025 12:06:10 +0200   
   David Brown wrote:   
      
   > On 10/10/2025 08:27, BGB wrote:   
   > > On 10/9/2025 10:59 PM, Keith Thompson wrote:    
   > >> bart writes:    
   >    
   > >>    
   > >>>> One merit is if code can be copy-pasted, but if one has to change   
   > >>>> all instances of:   
   > >>>> char *s0, *s1;   
   > >>>> To:   
   > >>>> char* s0, s1;   
   > >>>> Well, this is likely to get old, unless it still uses, or allows   
   > >>>> C style declaration syntax in this case.    
   > >>>   
   > >>> That one's been fixed (50 years late): you instead write:   
   > >>>   
   > >>> typeof(char*) s0, s1;   
   > >>>   
   > >>> But you will need an extension if it's not part of C23.    
   > >>   
   > >> Yes, that will work in C23, but it would never occur to me to   
   > >> write that. I'd just write `char *s0, *s1;` or, far more likely,   
   > >> define s0 and s1 on separate lines. Using typeof that way triggers   
   > >> my WTF filter.   
   > >>    
   > >    
   > > Agreed.   
   > >    
   > >    
   > >    
   > > I think it can be contrast with C# style syntax (with "unsafe")   
   > > where one would write:   
   > > char* s0, s1;    
   >    
   > Does C# treat s1 as "char*" in this case? That sounds like an    
   > extraordinarily bad design decision - having a syntax that is very   
   > like the dominant C syntax yet subtly different.   
   >    
      
   Generally, I disagree with your rule. Not that it makes no sense at   
   all, but sometimes a violation has more sense. For example, I strongly   
   prefer for otherwise C-like languages to parse 011 literal as decimal   
   11 rather than 9.   
      
   In this particular case it's more subtle.   
   What makes it a non-issue in practice is the fact that pointers is C# is   
   very rarely used expert-level feature, especially so after 7 or 8   
   years ago the language got slices (Span).   
   A person that decides to use C# pointers has to understand at least   
   half a dozen of more arcane things than this one.   
   Also it's very unlikely in case somebody made such mistake that his   
   code will pass compilation. After all, we're talking about C# here, not   
   something like Python.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|