• Prime Mover (unregistered)

    "Regirously": Is that "rigorously and religiously"? It's well worth adding it to the English language.

  • MiserableOldGit (unregistered) in reply to Prime Mover

    You beat me to it, with a better remark than I had.

  • (nodebb)

    It's great to have your month-names in an array. For that time of the year, we decide to add a new one.

    Addendum 2020-12-16 07:55: I would suggest to implement months as a state-machine, as ordering seems really important :D

  • Richard Smithers (unregistered)

    Shouldn't they have noticed it in August? I can see July still working as it probably truncates the name to the first three characters.

  • Thomas J. (unregistered)

    It always amazes me that people are able to program in C but miss that the array would be better in every way like this:

    static const char month_name[][3] = {
        "Jan",
        "Feb",
        "Mar",
        "Apr",
        "May",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Oct",
        "Nov",
        "Dec"
    };
    
  • (nodebb)

    I remember my JulAug, 2020. It was great! I traveled to FloridaTexas, and ate a lot of steakribs.

  • Jaloopa (partially registered) (unregistered)

    Who on Earth ever considered that misfeature worthy of adding to the language? This kind of bug has to be all over the place.

  • dpm (unregistered) in reply to Jaloopa (partially registered)

    Perhaps you haven't had to spend a lot of time working with the C preprocessor.

  • Brian (unregistered) in reply to Jaloopa (partially registered)

    You know, back in the day when C was created, not everyone had the luxury of 4K monitors that could easily fit a couple hundred characters per line. Having ways of splitting up long lines to keep the code readable was definitely a useful feature. Also keep in mind that there are no string concatenation or interpolation operators in C. So either you glob your string fragments together with sprintf (which costs cycles), or you use built-in language features to keep it as a compile-time constant.

  • (nodebb) in reply to Brian

    Still a language WTF. They could have allowed compile time concatenation using +, which would've made sense and been more resistant to typos.

  • Wut (unregistered) in reply to Jaloopa (partially registered)

    Python does this.

    See e.g. https://tio.run/##K6gsycjPM/7/Pzc/ryQjPi8xN1XBViGaSwEIlLwS85R0IEy31CQY0zexCMZ0LChCiFbCmF6leQhmjhJUaWk6TDA4tQDG9E8ugTH98stgTJfUZCWuWGsuroKizLwSDYTTos1iNa3//wcA for a live example.

  • (nodebb)

    It's useful for inserting preprocessor macros into string literals.

    #define FOO "abc"
    char abc[] = "123" FOO "456";
    
  • (nodebb) in reply to Thomas J.

    It always amazes me that people are able to program in C but miss that the array would be better in every way like this:

    The cited "this" begins with this:

    static const char month_name[][3] = {
        "Jan",
        "Feb",
    

    which is almost infinitely worse, since there's actually only one string in there, and no room for \000 terminators anywhere, not even at the end.

    Or maybe that's the point...

  • Thomas J. (unregistered) in reply to Steve_The_Cynic

    Yes, I immediately noticed, but couldn't correct it because of how commenting here works.

  • Foo AKA Fooo (unregistered) in reply to Prime Mover

    It's "rigirously" now. I thought I'd seen every misspelling of that word. ;)

    Also *eighth.

  • (nodebb)

    Given that 99&44/100 % of all code lines are short (less than 80 char or whatever your console is set to), I never could figure out why any language decided that a line feed was not a valid end-of-line delimiter, and that some specific character should be used to force a continuation over a line break. For example, MATLAB (which has its own host of problems) ends things at a CR or line break unless you specifically type three periods -- "..." , not an ellipsis.

    R is even smarter: if a command is incomplete, it keeps looking past CRs until a valid completion ( close brackets, etc) is found.

  • Sole Purpose Of Visit (unregistered) in reply to cellocgw

    Well, first of all, C isn't a language so much as a very sophisticated cross-platform assembler. Or, to be more accurate, K,R & P were motivated to produce the best possible version of the latter, rather than the best possible version of the former. And they did a wonderful job of precisely that.

    Beyond that, it's a lexical choice, really. I think you underestimate the number of ridiculously long lines of code, but, even if not, I wish to point out that LF is just another ASCII character (remember, C was designed for ASCII), and unfortunately for us all, the EOL for Macs differed from the EOL for DOS differed from the EOL for *nix. So, in fact, if you wanted a cross-platform solution, you pretty much had to use something like a semi-colon (or comma, in this case).

    And concatenation via a plus would have gone against the way that C works, of course, since a literal "string" is just a pointer (and has to be, unless you want to rewrite half the libraries). Adding two pointers does not a concatenation make.

    There are worse "gotchas" in C than this. Operator precedence springs to mind. Not to mention the entire existence of the preprocessor, and if you haven't used the "##" preprocessor operator -- which was a promising but failed attempt to add string concatenation to the language -- then you haven't lived. Or not, at least, the life that I have lived. For which, be grateful.

  • (nodebb) in reply to Sole Purpose Of Visit
    I think you underestimate the number of ridiculously long lines of code,
    Ok, the number of **readable** lines of code :-)
  • WTFGuy (unregistered)

    @Mr. TA ref

    I remember my JulAug, 2020. It was great! I traveled to FloridaTexas, and ate a lot of steakribs.

    So you're the guy who spread all that COVID! Traveling to the places with no rules and an oblivious public, then hanging out in restaurants. Probably drank a lot of beerscotch too.

    Gee thanks. ;)

  • Sole Purpose Of Visit (unregistered) in reply to cellocgw

    Fair 'nuff. But I remember (me being bat blind) working on VDUs in the 1990s, where some idiot had decided to switch them to 132 char mode (rather than the standard 80). Guess why he did that?

    Well, OK, a good guess was that "he was an arrogant moron who didn't care about anybody else who might use that VDU." A really good guess, in fact. But his main rationale, if I can call it that, was that a significant proportion of his (C) code ran to more than eighty characters a line. I'm talking almost 50% here.

    But back to the specificity in question. I think I might have actually come up with what K, R & P should have done, to avoid this problem. To whit: disallow pairings of quoted strings [I]in all cases[I], precisely because of the opportunity for today's WTF. If you want to concatenate strings, use a preprocessor macro.

    (In which macro, ironically, you can use as much whitespace and as many EOLs of any kind as you like. An accidental benefit, but fun nonetheless.)

    As fpr "beerscotch?" My scottish brethren are way ahead of you on that one. A pint of heavy and a chaser ... but make sure you don't put ice cubes in the chaser, which would be Against God's Will.

    A sufficiency of near room temperature water would do.

  • ClosetDBA (unregistered)

    SQL has a similar gotcha

    SELECT TheFirstColumn, TheSecondColumn TheThirdColumn FROM somewhere

    You get 2 columns in the output. Missing the comma, it reads as a column alias: SELECT TheFirstColumn, TheSecondColumn AS TheThirdColumn...

  • (nodebb)

    JulAug is a monolithic block where everyone is on vacation [was actually pretty true 40-70 years ago]

  • WTFGuy (unregistered)

    @Sole Purpose Of Visit Ref

    As fpr "beerscotch?" My scottish brethren are way ahead of you on that one. A pint of heavy and a chaser ... but make sure you don't put ice cubes in the chaser, which would be Against God's Will.

    A sufficiency of near room temperature water would do.

    Given that "room temperature" in Scotland is generally ~15C and certainly no higher than 20C that works. ;)

Leave a comment on “Stringing Your Date Along”

Log In or post as a guest

Replying to comment #:

« Return to Article