• Re: Block Comments Or Rest-Of-Line Comments?

    From DFS@nospam@dfs.com to comp.lang.c on Tue Apr 23 16:13:34 2024
    From Newsgroup: comp.lang.c

    On 3/21/2024 2:19 AM, Lawrence D'Oliveiro wrote:
    I’m fond of writing things like

    /*
    A very simple HTML/XML entity-escape function--why isn’t this
    part of the standard Java API?
    */

    which involve less typing than

    //
    // A very simple HTML/XML entity-escape function--why isn’t this
    // part of the standard Java API?
    //

    Get yourself some Notepad++.

    Highlight a block of comments and hit Ctrl + Q.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Kaz Kylheku@643-408-1753@kylheku.com to comp.lang.c on Tue Apr 23 21:06:54 2024
    From Newsgroup: comp.lang.c

    On 2024-03-21, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    Also, the “block” form allows “interspersed” comments, where a short comment can be put in the middle of a line and followed by more program
    text in the rest of the line. For example, as a way of keeping long
    argument lists straight:

    gdImageCopyResampled
    (
    /*dst =*/ ResizedFrame,
    /*src =*/ Context.StillFrame,
    /*dstX =*/ 0,
    /*dstY =*/ 0,
    /*srcX =*/ 0,
    /*srcY =*/ 0,
    /*dstW =*/ ResizedFrame->sx,
    /*dstH =*/ ResizedFrame->sy,
    /*srcW =*/ Context.StillFrame->sx,
    /*srcH =*/ Context.StillFrame->sy
    );

    Do you feel the same?

    A normal person won't compulsively comment very function argument,
    but if they had to do it, here is what it might look like:

    gdImageCopyResampled(ResizedFrame, // dst
    Context.StillFrame, // src
    0, 0, 0, 0, // {dst,src}{X,Y}
    ResizedFrame->sx, // dstW
    ResizedFrame->sy, // dstH
    Context.StillFrame->sx, // srcW
    Context.StillFrame->sy); // srcH

    gdImageCopyResampled(ResizedFrame, /* dst */
    Context.StillFrame, /* src */
    0, 0, 0, 0, /* {dst,src}{X,Y} */
    ResizedFrame->sx, /* dstW */
    ResizedFrame->sy, /* dstH */
    Context.StillFrame->sx, /* srcW */
    Context.StillFrame->sy); /* srcH */

    Using either kind of comment, it goes at the end of the line, with a
    decent amount of space. The reader of the code who doesn't find
    the comments helpful can easily ignore them.
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lowell Gilbert@lgusenet@be-well.ilk.org to comp.lang.c on Tue Apr 23 19:25:04 2024
    From Newsgroup: comp.lang.c

    Kaz Kylheku <643-408-1753@kylheku.com> writes:

    A normal person won't compulsively comment very function argument,

    Well, they might if they're generating documentation from the comments.
    Even then, it would usually only be a concern for API-type functions,
    which means a fairly small share of a typical codebase.

    The original post is kind of weird, though, in that its author's idea of
    what it easy to type seems to be based on writing code out on a
    typewriter. Maybe a Teletype without a C-savvy editor program.

    Be well.
    --
    Lowell Gilbert, embedded/networking software engineer
    http://be-well.ilk.org/~lowell/
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ben Bacarisse@ben.usenet@bsb.me.uk to comp.lang.c on Wed Apr 24 01:12:41 2024
    From Newsgroup: comp.lang.c

    Lowell Gilbert <lgusenet@be-well.ilk.org> writes:

    Kaz Kylheku <643-408-1753@kylheku.com> writes:

    A normal person won't compulsively comment very function argument,

    Well, they might if they're generating documentation from the
    comments.

    The discussion was about function arguments in a call. Documentation
    would, presumably, be generated from comments on (formal) parameters in
    a function declaration.
    --
    Ben.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lowell Gilbert@lgusenet@be-well.ilk.org to comp.lang.c on Tue Apr 23 20:26:34 2024
    From Newsgroup: comp.lang.c

    Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

    Lowell Gilbert <lgusenet@be-well.ilk.org> writes:

    Kaz Kylheku <643-408-1753@kylheku.com> writes:

    A normal person won't compulsively comment very function argument,

    Well, they might if they're generating documentation from the
    comments.

    The discussion was about function arguments in a call. Documentation
    would, presumably, be generated from comments on (formal) parameters in
    a function declaration.

    Fair enough. I drifted too far.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Kaz Kylheku@643-408-1753@kylheku.com to comp.lang.c on Wed Apr 24 00:58:37 2024
    From Newsgroup: comp.lang.c

    On 2024-04-23, Lowell Gilbert <lgusenet@be-well.ilk.org> wrote:
    Kaz Kylheku <643-408-1753@kylheku.com> writes:

    A normal person won't compulsively comment very function argument,

    Well, they might if they're generating documentation from the comments.
    Even then, it would usually only be a concern for API-type functions,
    which means a fairly small share of a typical codebase.

    I think here you're thinking more of formal parameters, rather than
    argument expressions in calls.
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.lang.c on Wed Apr 24 07:49:19 2024
    From Newsgroup: comp.lang.c

    On Tue, 23 Apr 2024 16:13:34 -0400, DFS wrote:

    On 3/21/2024 2:19 AM, Lawrence D'Oliveiro wrote:

    I’m fond of writing things like

    /*
    A very simple HTML/XML entity-escape function--why isn’t this part
    of the standard Java API?
    */

    which involve less typing than

    //
    // A very simple HTML/XML entity-escape function--why isn’t this
    // part of the standard Java API?
    //

    Get yourself some Notepad++.

    Highlight a block of comments and hit Ctrl + Q.

    Get an inferior piece of software, available only on an inferior platform, just to turn a comment style that I like into one I don’t like?

    What next: you want me to give up my car for a rickshaw, and move to a
    village on top of a cliff?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Blue-Maned_Hawk@bluemanedhawk@invalid.invalid to comp.lang.c on Wed Apr 24 12:36:40 2024
    From Newsgroup: comp.lang.c

    DFS wrote:

    Get yourself some Notepad++.

    Not everybody can afford a machine powerful enough for a fancy text editor like that.
    --
    Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr. blue-maned_hawk.srht.site
    “You know what that means.” “No i don't.”
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Sjouke Burry@burrynulnulfour@ppllaanneett.nnll to comp.lang.c on Wed Apr 24 21:41:37 2024
    From Newsgroup: comp.lang.c

    On 24.04.24 14:36, Blue-Maned_Hawk wrote:
    DFS wrote:

    Get yourself some Notepad++.

    Not everybody can afford a machine powerful enough for a fancy text editor like that.



    BULSHIT.
    I run notepad++ on a 20 year old xp pro machine, and never
    had a problem.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Blue-Maned_Hawk@bluemanedhawk@invalid.invalid to comp.lang.c on Thu Apr 25 03:48:40 2024
    From Newsgroup: comp.lang.c

    Sjouke Burry wrote:

    On 24.04.24 14:36, Blue-Maned_Hawk wrote:
    DFS wrote:

    Get yourself some Notepad++.

    Not everybody can afford a machine powerful enough for a fancy text
    editor like that.



    BULSHIT.
    I run notepad++ on a 20 year old xp pro machine, and never had a
    problem.

    I don't see how that refutes my claim instead of substantiating it.
    --
    Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr. blue-maned_hawk.srht.site
    Bribe^WLoan^WCompensation
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From DFS@nospam@dfs.com to comp.lang.c on Thu Apr 25 10:14:23 2024
    From Newsgroup: comp.lang.c

    On 4/24/2024 8:36 AM, Blue-Maned_Troll wrote:
    DFS wrote:

    Get yourself some Notepad++.

    Not everybody can afford a machine powerful enough for a fancy text editor like that.


    Notepad++ will run on $25 dumpster hardware.






    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Blue-Maned_Hawk@bluemanedhawk@invalid.invalid to comp.lang.c on Thu Apr 25 22:10:54 2024
    From Newsgroup: comp.lang.c

    DFS wrote:

    On 4/24/2024 8:36 AM, Blue-Maned_Troll wrote:

    That's an unsubstantiated claim.

    DFS wrote:

    Get yourself some Notepad++.

    Not everybody can afford a machine powerful enough for a fancy text
    editor like that.


    Notepad++ will run on $25 dumpster hardware.

    So what? Not everybody can afford a machine that powerful.
    --
    Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr. blue-maned_hawk.srht.site
    I wish i had a brain. I also wish i had a crunch bar.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c on Thu Apr 25 19:33:19 2024
    From Newsgroup: comp.lang.c

    On 4/25/2024 3:10 PM, Blue-Maned_Hawk wrote:
    DFS wrote:

    On 4/24/2024 8:36 AM, Blue-Maned_Troll wrote:

    That's an unsubstantiated claim.

    DFS wrote:

    Get yourself some Notepad++.

    Not everybody can afford a machine powerful enough for a fancy text
    editor like that.


    Notepad++ will run on $25 dumpster hardware.

    So what? Not everybody can afford a machine that powerful.

    If one cannot afford a 25 dollar computer, well, shit...
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From DFS@nospam@dfs.com to comp.lang.c on Thu Apr 25 22:44:58 2024
    From Newsgroup: comp.lang.c

    On 4/25/2024 6:10 PM, Blue-Maned_Troll trolled again:
    DFS wrote:

    On 4/24/2024 8:36 AM, Blue-Maned_Troll wrote:

    That's an unsubstantiated claim.

    That's a fact.


    DFS wrote:

    Get yourself some Notepad++.

    Not everybody can afford a machine powerful enough for a fancy text
    editor like that.


    Notepad++ will run on $25 dumpster hardware.

    So what? Not everybody can afford a machine that powerful.

    Not the crowd you run with anyway.





    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From paul@paul@paulglover.net.invalid to comp.lang.c on Fri Apr 26 22:32:34 2024
    From Newsgroup: comp.lang.c

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    Since then, I’ve seen newer programmers gravitate towards the rest-of-line form in preference to the block form, and I’m not sure why. I’m fond of writing things like

    /*
    A very simple HTML/XML entity-escape function--why isn’t this
    part of the standard Java API?
    */

    which involve less typing than

    //
    // A very simple HTML/XML entity-escape function--why isn’t this
    // part of the standard Java API?
    //

    For me, it's block form for larger blocks of comment (descriptive stuff, really, where a lot of info is needed).

    Shorter comments use the rest-of-line form.

    Since most of the comments I put in code are short (usually just to
    describe what the next section does, if necessary, and typically are a
    single line) they end up being mostly rest-of-line.

    At work, with the autodoc system we use in Visual Studio, it requires
    comment blocks which have 3 slashes ( /// ). Not a fan, but no choice
    there either.


    Also, the “block” form allows “interspersed” comments, where a short comment can be put in the middle of a line and followed by more program
    text in the rest of the line. For example, as a way of keeping long
    argument lists straight:

    gdImageCopyResampled
    (
    /*dst =*/ ResizedFrame,
    /*src =*/ Context.StillFrame,
    /*dstX =*/ 0,
    /*dstY =*/ 0,
    /*srcX =*/ 0,
    /*srcY =*/ 0,
    /*dstW =*/ ResizedFrame->sx,
    /*dstH =*/ ResizedFrame->sy,
    /*srcW =*/ Context.StillFrame->sx,
    /*srcH =*/ Context.StillFrame->sy
    );

    Ewww, no. That's a perfect case for end-of-line rest-of-line comments
    after each line. Or refactoring the function signature somehow if
    possible because that's a lot of parameters. Interspersed is just
    messy-looking IMO. :)

    One use for this though: if I'm making temporary changes to test
    something out, I'll often comment out a bit of a line using /* .. */ but it's solely for test purposes, and never ends up being committed.

    Also some of this becomes moot anyway if a project has style guidelines,
    not to mention automation in some editors (it's only more typing if the
    editor doesn't autocomplete it for you).
    --
    Paul.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From paul@paul@paulglover.net.invalid to comp.lang.c on Fri Apr 26 22:41:36 2024
    From Newsgroup: comp.lang.c

    Kaz Kylheku <433-929-6894@kylheku.com> wrote:
    I have a simpler approach: commits which introduced commented-out
    code, whether with #if 0, or any other means, shall not be merged.

    I don't perpetrate that in my open source projects, and "-1" such
    submissions at work.

    When someone wants to remove code, I encourage them to actually
    delete it. The comment about why it was deleted goes into the
    commit log.

    Yes!! Every time a dev checks in dead code, $DEITY kills a small furry
    creature out of spite.

    Maybe it was appropriate 40 years ago before we had version control
    systems, but we do now, and code deleted that needed to stay can easily
    be brought back from the void. (I just had to do that in my day job, an "unused" line which the IDE flagged actually was important and removing
    it caused a runtime error. It was a 5 second fix when I could just pull
    up the change details and pull the line back in.)
    --
    Paul.

    --- Synchronet 3.20a-Linux NewsLink 1.114