• (nodebb)

    My money is on this being a WTF.

    But it is conceivable that it can be used to change the collection size in much the same way that StringBuilder.Length is used. I have on occasion used StringBuilder for doing things like comma separated lists where the last item must not have a comma and I can achieve it like so:

    foreach (var item in list)
    {
      sb.Append(item);
      sb.Append(", ");
    }
    
    sb.Length -= 2;
    
  • (nodebb)

    For example, the HMI's API provides its own set of collection types, in C#. We can wonder why they'd do such a thing,

    My best guess would be that it began life as a sort of proto-C++, back well before the arrival of C++98's STL, or maybe even just plain C, and was then "ported" to C-flat, and management said, "You shall port all the old code, really all of it. We'll get someone from outside to audit what you did, and if the auditors find anything that wasn't ported, there will be seventy-three kinds of Hell to pay!" So they did exactly what they were told, and left nothing of the old code out of the port, for fear that management really meant "three hundred seventy" when they said "seventy-three".

    which is certainly a WTF in itself,

    No, wondering about it is not a WTF. Well, maybe it is. Maybe the correct verb is "despair"...

  • (nodebb)

    I mean, writable length properties are not really that special, System.IO.Stream has one of those as well, as do various builders like StringBuilder.

  • (nodebb)

    A lot of people just automatically make getters and setters for all properties because they don't really know why they're supposed to have private variables.

  • (nodebb) in reply to konnichimade

    This seems most likely.

  • Alessandro Mandelli (unregistered)
    Comment held for moderation.
  • Joe (unregistered) in reply to Steve_The_Cynic

    That sounds plausible to me. I interned at a company that builds such machines around the turn of the century and they were using plain C at the time.

  • (nodebb) in reply to konnichimade

    A lot of people just automatically make getters and setters for all properties because they don't really know why they're supposed to have private variables.

    I think you have a wrong word in there. Try this instead:

    A lot of people just automatically make getters and setters for all properties because they don't really know that private variables are supposed to be, well, private or, at most, read-only from the outside.

  • Vera (unregistered) in reply to Jonathan Lydall

    As pointed out in the highlighted comment of 2026-02-18's article, why not do something to the effect of, "if there is more than one item in the list, add the first one to the stringbuilder, then for all the rest add a comma and the next item"? Means you don't have to remove anything at the end.

Leave a comment on “The Counting Machine”

Log In or post as a guest

Replying to comment #:

« Return to Article