• (disco) in reply to Tsaukpaetra

    You are a prime fuckwit.

    I quoted from a comment on the number of branches in the switch statements that are actually there. This was clearly documented to be 26 in each one of two. Someone then said that meant a total of 62 branches, whereas there are 52 branches (26*2).

    You assumed (decided without any evidence) I was talking about the number of possible branches if we are talking about the widest possible interpretation of alphanumeric, that all characters in all positions of all the strings might be upper case letters, lower case letters, or digits. And even then you got it wrong, because there is, if it is really that way, a total of (26+26+10) times 2 branches in the pair of switches. But there are not 26+26+10 in each one, just 26. The comments say so.

    Now fuck off and die.

  • (disco) in reply to Steve_The_Cynic
    Steve_The_Cynic:
    the widest possible interpretation of alphanumeric, that all characters in all positions of all the strings might be upper case letters, lower case letters, or digits

    And you only arrived at 62?

    $ awk -v FS=\; '$3 ~ /L./' UnicodeData.txt | wc -l
    12066
    

    EDIT: my apologies, we were talking about alphanumerics

    $ awk -v FS=\; '$3 ~ /[LN]./' UnicodeData.txt | wc -l
    12999
    
  • (disco)

    Damned englishists, assuming we all have 26 letters in our alphabets...

  • (disco) in reply to emkael

    Those people are stupid. Goto is evil because it is an arbitrary jump that results in spaghetti code. Break and return are part of a high-level structure (loop or function) and don't result in spaghetti code.

  • (disco) in reply to PleegWat

    Fair point. Sorry. The widest possible interpretation of unaccented Latin Alphabet/Arabic numeral alphanumeric. Good catch.

  • (disco) in reply to CoyneTheDup

    You should use if ("AA01".equals(wk_code)) etc. instead to minimize the number of possible NPEs. (In general, it is less likely that a literal constant is non-null than a variable.)

    If we'd check for wk_code being non-null before, we could optimize the code a bit:

    string res;
    if (wk_code != null && wk_code.length > 0 && wk_code[0].equals("A")) {
      if (wk_code != null && wk_code.length > 1 && wk_code[1].equals("A")) {
        if (wk_code != null && wk_code.length > 2 && wk_code[2].equals("0")) {
          if(wk_code != null && wk_code.length > 3 && wk_code[3].equals("1")) {
            res = "Error AA01 Descrigth > 2 && wk_code[2].equals("; // luckily, I don't make C&P-errors
          } else if (wk_code != null && wk_code.length > 3 && wk_code[3].equals("2")) {
    // half a bazillion lines of auto-generated and manually changed code goes here (C&P-d error descriptions from an OCR-ed scan of the handbook)
    

    Well, I think the lines consisting of single curly braces should be kept for they perform better in a PPL environment.

  • (disco) in reply to RFoxmich

    In fact, in this case using std::map<> is always slower than using the original array lookup.

    The map is created using static constructor on application initialization, so it will use O(n) time during every program start. Whereas the O(n) array lookup is only done on error exit, which hopefully does not happen every time.

    Original code is fine, though it would be cleaner if everything was just in a single const array.

  • (disco) in reply to jpa

    If something is happening to initialize the map at runtime, your compiler sucks.

  • (disco) in reply to LB_

    Please tell me, does there then exist a C++ compiler that does not suck? Both clang and gcc generate runtime initialization for your code, even if the variable is const and even if -O3 is enabled.

  • (disco) in reply to jpa

    I don't know. But I do know that it's entirely within reason that a compiler could do it. Have you tried Intel? I've heard it does some weird optimizations like loop interchange.

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    @Blakeyrat any thoughts?

    I didn't read any of that and fuck you.

  • (disco) in reply to LB_

    How do you suggest it would work? Would the data reside in heap or in .text? Would there have to be a constexpr-based based implementation of std::map and std::string, or would the compiler go executing random pieces of code during compilation?

  • (disco) in reply to jpa
    jpa:
    Both clang and gcc generate runtime initialization for your code

    And Visual Studio 2015, in both debug and release configurations.

  • (disco) in reply to Khudzlin
    Khudzlin:
    Those people are stupid. Goto is evil because it is an arbitrary jump that results in spaghetti code. Break and return are part of a high-level structure (loop or function) and don't result in spaghetti code.

    Indeed. With proper use of break/return/continue/insert-another-coin you will end up with schupfnudel[1] code, or at worst penne[2] code because you have strict rules on how the program flow can be altered, leaving you with well defined dumplings[3] which can be dipped in sauce[4] as you eat them. Once you start adding unrestricted gotos[5] into the mix then you run the risk of turning your code into a block of instant ramen[6].

    [1] It's like a cross between a dumpling and penne. [2] It's like schupfnudel, but not like a dumpling. [3] It's like the interference pattern when you send schupfnudels and penne through two tiny slits and then allow them to land on a plate on the other side. This experiment proves that pasta acts as both a particle and a wave at the same time, and that it would very much like you to take your classical interpretation of how food behaves and stuff it in an uncomfortable place.[7] [4] The sauce isn't a metaphor for anything at all. It's just in the story because if you're going to eat dumplings, you really should have a nice sauce to dip them in. [5] With no restrictions on the programmer, that is. An actual unrestricted GOTO would be the GOAWAY command, which always results in undefined behaviour. By definition. [6] The kind that comes in a square package, costs $0.49 and comes with a coupon for $0.50 off of your next package of instant ramen. If you have ever eaten this then it may be hard to believe that there exists another kind of ramen which is made with actual food and is served in fancy restaurants.[8] [7] Like in the back of a Volkswagen. [8] The kind which don't serve soup in styrofoam cups or coffee mugs. If you're a student then you'll just have to trust me when I say that such things exist.

  • (disco) in reply to DCRoss

    I ain't reading that tiny shit.

  • (disco) in reply to DCRoss

    It's too early for dinner.

  • (disco) in reply to Steve_The_Cynic
    blakeyrat:
    I didn't read any of that and fuck you.

    Thank you for you contribution ! :stuck_out_tongue_winking_eye:

    Steve_The_Cynic:
    You are a prime fuckwit.

    I'm TRYING to get a badge consarndit!

    Steve_The_Cynic:
    Someone then said that meant a total of 62 branches,
    that would be the article, no?
    Steve_The_Cynic:
    Now fuck off and die.
    I would, but,
    1. I have nobody to do that with.
    2. You do not have permission to execute that command
    3. I'm trying to get a badge, yet you seem to take it personal. It's way fun to see someone get all accusatory and inflammatory, so much so that they resort to vulgarity (being unable to eloquently express their thoughts anymore).
  • (disco) in reply to emkael

    Crypto-GOTO? Anathema! I am sure, you are always coding without drawing your Nassi–Shneiderman diagram first, right? ;-)

  • (disco) in reply to HardwareGeek
    HardwareGeek:
    It's an even worse mish-mash of C and C++ than I noticed at first.
    Not as bad as allocating with C++-style new and deallocating with C-style free - since there are no destructors anyway. :grin:
  • (disco) in reply to DCRoss
    DCRoss:
    If you have ever eaten this then it may be hard to believe that there exists another kind of ramen which is made with actual food and is served in fancy restaurants

    Mind you, it's still preferable over cup-a-soup.

    EDIT: Though I may be used to a higher quality of instant noodles than you.

  • (disco) in reply to DCRoss
    DCRoss:
    trust me

    Why?


    Filed under: Also, my favourite brand is Maruchan

  • (disco) in reply to jpa

    Considering that the standards keep relaxing constexpr constraints, I foresee a future where you could have a constexpr map of strings. I'm thinking too far ahead though - basically, at this point in time, you're right and I'm wrong.

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    DCRoss:
    trust me

    Why?

    Because I'm from the Internet, and speaking with a tone of authority about something which I obviously know nothing about.

    Who could be more trustworthy than that?

  • (disco) in reply to DCRoss
    DCRoss:
    [6] The kind that comes in a square package, costs $0.49 and comes with a coupon for $0.50 off of your next package of instant ramen. If you have ever eaten this then it may be hard to believe that there exists another kind of ramen which is made with actual food and is served in fancy restaurants.[8]

    http://ramenhakata.com/

    PleegWat:
    Mind you, it's still preferable over cup-a-soup.

    Yes, but the relation between ramen in packets and fancy restaurant ramen is analogous to the relation between mac-n-cheese in the blue box versus macaroni and cheese made from scratch by a good cook.

  • (disco) in reply to DCRoss
    DCRoss:
    block of instant ramen[6].

    [6] The kind that comes in a square package, costs $0.49 and comes with a coupon for $0.50 off of your next package of instant ramen.

    I would like to point out that calling this "instant" ramen is inaccurate. Those blocks of allegedly food-like ... stuff ... require three minutes of cooking (plus the time to bring the water to a boil prior to cooking). Three minutes != instant.

  • (disco) in reply to DCRoss
    DCRoss:
    The kind that comes in a square package, costs $0.49

    :doing_it_wrong:

    They were 14 for 99 cents last time I went to a 99 Cents Store

  • (disco) in reply to DCRoss
    DCRoss:
    The kind that comes in a square package, costs $0.49 and comes with a coupon for $0.50 off of your next package of instant ramen.

    I've never seen them come with a coupon, but they cost about $2 for a box of 12 packages.

  • (disco) in reply to HardwareGeek
    HardwareGeek:
    three minutes of cooking

    A mere three minutes? I usually keep them on for 20!

    @codinghorrorbot

  • (disco) in reply to Tsaukpaetra

    @‍Tsaukpaetra Is Doing It Wrong™

    <!-- SockBot/2.10.2 (Bewitching Burlap; owner:loopback0; user:CodingHorrorBot) 2015-10-23T20:28:19.621Z -->
  • (disco) in reply to HardwareGeek
    HardwareGeek:
    require three minutes of cooking

    The stuff I have is 'pour boiling water over it, wait for 3 minutes. No cooking. Unox, which is an unilever brand.

  • (disco) in reply to PleegWat
    PleegWat:
    pour boiling water over it, wait for 3 minutes. No cooking.

    IME, the cup-of-soup sort of stuff wants that; the brick-of-noodles wants the water to continue boiling for three minutes. Nissin definitely does; I just checked. However, I don't have any other brands available to check, so I'll take your word that at least some brands are satisfactory (for some definition of satisfactory) without actual cooking.

    It could be argued that "no cooking" puts those into the realm of "instant," sort of, but I'd still say 3 minutes != instant.

  • (disco) in reply to HardwareGeek

    Well, I think they recommend 3 minute wait for cup-a-soup as well. I don't tend to time it, but instead go by 'cooled down far enough to eat', combined with the brick of noodles having gone soft.

    Thinking on it further, I wouldn't be surprised if cup-a-soup is an unilever brand as well.

    EDIT: yup, cup-a-soup is unilever.

  • (disco) in reply to PWolff
    PWolff:
    (In general, it is less likely that a literal constant is non-null than a variable.)

    I think you reversed something there..

  • (disco) in reply to HardwareGeek
    HardwareGeek:
    I would like to point out that calling this "instant" ramen is inaccurate. Those blocks of allegedly food-like ... stuff ... require three minutes of cooking (plus the time to bring the water to a boil prior to cooking). Three minutes != instant.

    instant adj. anything that takes less time than mixing and cooking biscuits from scratch.

    I though everyone knew that, but maybe you had to be there when "instant" was invented. Like I was.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    biscuits from scratch

    Where do you start? Milling flour? Reaping wheat? Sowing wheat? Cross-breeding grasses to create wheat? Creating plant life?

  • (disco) in reply to PWolff
    PWolff:
    Where do you start? Milling flour? Reaping wheat? Sowing wheat? Cross-breeding grasses to create wheat? Creating plant life?

    With this recipe as a typical example. Note the prep time of 15 minutes, which you will spend on prep, and the cook time of 10 minutes.

    But I really shouldn't have chosen that as my example; I should have used traditional noodles, which require 10-15 minutes cooking in boiling water, and frequent stirring. As opposed to Ramen noodles, which are throw noodles and water in microwave and cook three minutes, during which time you can browse the web.

    The "instant" concept as envisioned by the food industry and began to appear circa '65 to '75, involved any elimination of the time-consuming and complex traditional "scratch" recipes, in favor of 1-2-3 step recipes with premixed ingredients that generally reduced the time to 25% or less of scratch preparation.

    You know how marketing is; the word "instant" was market-speak for very fast and very easy, so you didn't have to waste time cooking.

    That was not insignificant either. When I was a kid, my mother would spend anywhere from 30 to 60 minutes to prepare each meal, three meals a day; two hours of her day shot any way you looked at it. Because meal preparation was a continuous task, during which you did little else, because everything had to be timed to be ready at the same time.

    We also lived far from town (50 miles) and so one can't just run to the store: When we bought food it was for the next two weeks (i.e., she had to plan every meal for the next two weeks in advance) with additional on hand in case we couldn't get to town in that period. And self-canning, picking fruit for jams, butchering our own livestock, etc.

    Earlier in our history, it was worse. She told me one time that, when she was a little girl, ('40's) if you wanted beans for dinner, preparation started the day before with placing the dried beans on to soak.

    Generally hard for us to imagine spending an hour each meal, and all that preparatory planning, just to eat, when there's a pizza at our door 20 minutes after the phone call. (Heck, when I was a little kid, we didn't have a phone.)

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    everything had to be timed to be ready at the same time.

    Yeah this sucks, especially during feast meals like Thanksgiving "dinner"...

    CoyneTheDup:
    placing the dried beans on to soak.
    Wait, is there another way? We still sort our Pinto beans for rocks and runts before cooking the next day. Don't tell me they've "instant-ized" those too?
  • (disco) in reply to Tsaukpaetra

    I think I've only ever seen beans potted or canned.

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    Wait, is there another way? We still sort our Pinto beans for rocks and runts before cooking the next day.Don't tell me they've "instant-ized" those too?

    I see dried beans in the store, so people must still do the long soak, though you can get it down to an hour if you do it right. But I think most hurried people get their beans pre-soaked in a can, as suggested by @PleegWat.

  • (disco) in reply to LB_

    Partial evaluation is a thing, though it doesn't yet appear to have escaped the CS labs, in which the compiler does indeed go executing random pieces of code during compilation. All right: not random, but anything deterministic is fair game.

  • (disco) in reply to Watson
    Watson:
    Partial evaluation is a thing, though it doesn't yet appear to have escaped the CS labs

    It's used in compilers for many languages, but most function(al units) have so many hidden side-effects that only a very limited subset actually gets evaluated ahead of time. Languages that do more extensive pre-compilation effectively have to be designed with doing that in mind; for the rest it isn't worth going to the bother required. (The time and limited effort available are better spent making optimizations that users will actually see…)

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    Wait, is there another way? We still sort our Pinto beans for rocks and runts before cooking the next day.Don't tell me they've "instant-ized" those too?

    Well you can buy them in cans. Saves like 4 hours on your chili recipe and frankly I can't tell the difference.

  • (disco) in reply to Watson

    That's interesting, because my hobby language has specific syntax for differentiating expressions that should be evaluated at compile time, mainly because C++'s template syntax is horrible and I wanted to fix it in my language. Of course now I have problems like infinite loops and deep recursion to deal with...

  • (disco)

    I'm coming into this a bit late, and will probably get flamed. But:

    What is wrong with using an associative array?

    ErrorDescription[*errorCode*] = "*errorMessage*";
    
    
    function GetErrorMessage (*errorCode*) {
        return errorDescription[*errorCode*]
    }
    

    The Function can be a "wrapper" to any persistent store of the error descriptions.

    errorCode, by definition has to be made up of characters that should be legal for the array, or index to a table. Also, by definition, there are going to be unique and need not be ordered

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    the definition of assume

    Do we need a donkey-head :badger: ?

  • (disco) in reply to loose

    You need to construct it runtime, so a linear scan is faster, since you're only searching once.

  • (disco) in reply to ScholRLEA
    ScholRLEA:
    donkey-head :badger: ?
    YES! YES! GIVE ME ALL THE :badger:s!

    Also: :giggity:.

  • (disco) in reply to PleegWat

    I read your reply and, as I often do (to some posts in general), heard this:

    https://www.youtube.com/watch?v=ss2hULhXf04

    Which seemed to make more sense. I am sure what you said makes some sense to somebody, but my view is: That is like saying something along the lines of "...having a 100,000 line product inventory database table is a complete waste if somebody only looks at one Product..."

  • (disco) in reply to loose

    It's a compiled language thing. Read the thread.

  • (disco) in reply to PleegWat

    I fail to see the relevance. Pre-compiled, runtime compiled, or just plucked out of the air. The list of descriptions exist as an (in this case) associative array and when "something" spits out an error code (which may not be fatal, so there may be more of them), then the associated text is available

Leave a comment on “A Well Mapped Error”

Log In or post as a guest

Replying to comment #:

« Return to Article