From: david.brown@hesbynett.no   
      
   On 10/10/2025 16:28, Michael S wrote:   
   > 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.   
      
   I did not intend to describe a general rule (and I agree with you in   
   regard to octal).   
      
   >   
   > 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.   
   >   
      
   Sure.   
      
   It would seem to me, however, that it would have been better for the C#   
   designers to pick a different syntax here rather than something that   
   looks like C, but has subtle differences that are going to cause newbies   
   confusion when they try to google for explanations for their problems.   
   For example, if raw pointers are rarely used, then they should perhaps   
   be accessible using a more verbose syntax than a punctuation mark -   
   "ptr s0, s1;" might work.   
      
   However, I have no experience with C#, and don't know the reasons for   
   its syntax choices.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|