• (disco)
    public static string[] VALID_FRISTS = new string[] 
    {
        "frist",   // English
        "erste",   // German
        "première",     // French
        "最初",    // Japanese
        "처음으로",    // Korean
        "første",   // Danish
        "ensimmäinen",     // Finnish
        "första",   // Swedish
        "første",    // Norwegian
        "eerste",    // Dutch
        "primero"     // Spanish
    };
    
  • (disco)

    Did I just read this article on TDWTF?

    ... I am losing faith...

  • (disco)

    That sounds familiar

    EDIT: replacing one _ with %5F in the href so Discourse doesn’t replace my valid link with an invalid one.

  • (disco) in reply to VinDuv
    VinDuv:
    That <a href="http://thedailywtf.com/articles/Laying_the_Foundation_for_i18n,_Brick_by_Brick">sounds</a> <a href="http://thedailywtf.com/articles/Classics-Week-Laying-the-Foundation-for-i18n%2c-Brick-by-Brick">familiar</a>…

    Result from first link: [image]

    TheDailyWTF now has it's own "error while displaying the error" Error'd.

    Also: WHAT! Thats literally the same WTF!

  • (disco) in reply to Zacrath
    Zacrath:
    Result from first link:
    Some _’s in the href are replaced with <em></em>. Paging @discoursebot…
  • (disco) in reply to VinDuv

    @VinDuv - Days Since Last Discourse Bug: 0

    <!-- Posted by SockBot 0.13.0 "Devious Daine" on Mon Nov 03 2014 06:30:14 GMT+0000 (UTC)-->
  • (disco) in reply to VinDuv

    Wow. I am truly impressed by your searching skills / memory.

    Oh look, @Remy wrote a comment about all this:

    <!-- Jannik actually submitted this a REALLY long time ago, but it's been lurking in the inbox all this time. His co-workers, former and present, will likely be able to identify their workplace from the title, which Jannik requested we use. -->

    That's why you put E-Mails that have been successfully worked on into a separate folder!

  • (disco) in reply to aliceif
    aliceif:
    I am truly impressed by your searching skills / memory.

    Thanks. I tend to only remember completely useless things, though... (at least looking for “Deulish” was easy enough)

  • (disco) in reply to discoursebot
    discoursebot:
    @VinDuv - Days Since Last **Discovered Undocumented Discourse Feature**: 0

    FTFY.

    Yes, I know you're a bot.

    No, I don't care.

  • (disco) in reply to VinDuv
    VinDuv:
    That <a href="http://thedailywtf.com/articles/Laying_the_Foundation_for_i18n,%5fBrick_by_Brick">sounds</a> <a href="http://thedailywtf.com/articles/Classics-Week-Laying-the-Foundation-for-i18n%2c-Brick-by-Brick">familiar</a>…

    EDIT: replacing one _ with %5F in the href so Discourse doesn’t replace my valid link with an invalid one.

    What, a repost? I want my money back!
  • (disco) in reply to VinDuv

    So the original was in C# and this one is in Java. I can just see it now. "Well, this is how I wrote it while working for another company. I can do the same here, but in Java this time."

  • (disco) in reply to Nutster

    Java? Java uses Strings. Not strings.

  • (disco)

    Let's count the WTFs, shall we?

    1. Using a string array instead of an enum;
    2. Not using the appropriate ISO-codes;
    3. comparing each individual letter instead of the entire string;
    4. Looping over all the strings instead of an Array.Contains() function.
    5. Passing the entire url instead of just the code;
    6. The fact that this has already been released before, twice even.
  • (disco) in reply to Nzall
    Nzall:
    The fact that this has already been released before, twice even.

    The second was a "Classic WTF" article. Doesn't count.

  • (disco)

    Apparently the server does not see fit to preview the comments.

    [image]
  • (disco) in reply to abarker

    Very odd, it used to work earlier.

    The Frontpage is no longer worthy of Discourse's comments.

  • (disco) in reply to Zacrath
    Zacrath:
    The second was a "Classic WTF" article. Doesn't count.

    Yes it does. He gets two links to read how not to do it.

    Yes, TDWTF is mandatory reading for any professional :)

  • (disco)

    TRWTF is 12 space indents.

  • (disco)

    Hey, at least this structure is infinitely extensible!

    if ( turtle) { if ( turtle) { if ( turtle) { if ( turtle) { ... ... ... return (allthewaydown.txt) } ... ... } } }

  • (disco) in reply to cellocgw

    :facepalm:

    just.... just :facepalm:

  • (disco) in reply to VinDuv
    VinDuv:
    That sounds27 familiar18…
    Ah, the joys of Discourse's idiotic click counters.
  • (disco) in reply to accalia

    Hey now, that was funny.

  • (disco) in reply to VinDuv
    VinDuv:
    That sounds familiar…
    That sounds32 familiar21…
    Zylon:
    VinDuv: That sounds27 familiar18…

    Ah, the joys of Discourse's idiotic click counters.

    Hmm, only happens when I copy-paste. Apparently using the Quote tool "works just fine". :white_check_mark:

  • (disco) in reply to cellocgw

    You gave up after finite tries?

    while (turtle); return (notallthewaydown.txt);

  • (disco) in reply to xaade
    xaade:
    You gave up after finite tries?

    while (turtle); return (notallthewaydown.txt);

    hmmm......

  • (disco) in reply to discoursebot

    Wouldn't it be more appropriate to use the "minutes" unit? Or even seconds?

  • (disco) in reply to xaade
    xaade:
    while (turtle); return (notallthewaydown.txt);
    But you got rid of the nested statements. This is the proper way:
    template <int i = 0>
    bool isTurtlesAllTheWayDown()
    {
        if (turtlesHere(i) {
            return isTurtlesAllTheWayDown<i+1>();
        } else {
            return not true;
        }
    }
    

    Filed under: If C macros were recursive, it would be not only infinite buttembly but also infinite source file

  • (disco) in reply to Gaska

    Wait. If I understand C++ templates.... that won't finish compiling.

    Because it has to make an instance of the function for every possible content of the <>.

  • (disco) in reply to xaade

    that is a malformed template, sure.

    it won't complete compiling successfully ever, but it may eventually complete with error.

  • (disco) in reply to accalia

    Actually, assuming you're not targetting abstract Turing machine, I think it should stop at 4294967296th specialization, which shouldn't be outside of today's computers reach. Can't test right now though.

    Also, I would nominate you two for not getting the joke badge if I knew how.

  • (disco) in reply to Gaska

    flag as notify moderators and mention the badge you are flagging for.

    of course there's the possiblility we got the joke and decided to play along rather than calling you out on it. :smiley: i know that's what i was doing (although the mods might disagree)

  • (disco) in reply to accalia
    accalia:
    of course there's the possiblility we got the joke and decided to play along rather than calling you out on it. i know that's what i was doing (although the mods might disagree)
    It would be more believable if you hearted my post.
  • (disco) in reply to Gaska

    maybe. like i said the mods might disagree with my assertion that i got the joke.

  • (disco) in reply to xaade
    xaade:
    Because it has to make an instance of the function for every possible content of the <>.
    [postgres@sofa tmp]$ cat turtles.cpp 
    bool turtlesHere(int i){
            return false;
    }
    
    template <int i = 0>
    bool isTurtlesAllTheWayDown()
    {
        if (turtlesHere(i)) {
            return isTurtlesAllTheWayDown<i+1>();
        } else {
            return not true;
        }
    }
    
    int main(void){
            return isTurtlesAllTheWayDown();
    }[postgres@sofa tmp]$ gcc turtles.cpp -o turtles -std=c++11
    turtles.cpp:9:44: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) substituting 'template<int i> bool isTurtlesAllTheWayDown() [with int i = 900]'
    turtles.cpp:9:44:   recursively required from 'bool isTurtlesAllTheWayDown() [with int i = 1]'
    turtles.cpp:9:44:   required from 'bool isTurtlesAllTheWayDown() [with int i = 0]'
    turtles.cpp:16:32:   required from here
    
    turtles.cpp:9:44: error: no matching function for call to 'isTurtlesAllTheWayDown()'
    turtles.cpp:9:44: note: candidate is:
    turtles.cpp:6:6: note: template<int i> bool isTurtlesAllTheWayDown()
    turtles.cpp:6:6: note:   substitution of deduced template arguments resulted in errors seen above
    [postgres@sofa tmp]$ 
    
    Gaska:
    Actually, assuming you're not targetting abstract Turing machine, I think it should stop at 4294967296th specialization, which shouldn't be outside of today's computers reach. Can't test right now though.

    Even 99,999 takes bloody ages though. Not going to even try deeper:

    [postgres@sofa tmp]$ time gcc turtles.cpp -o turtles -std=c++11  -ftemplate-depth=999 
    turtles.cpp:9:44: error: template instantiation depth exceeds maximum of 999 (use -ftemplate-depth= to increase the maximum) substituting 'template<int i> bool isTurtlesAllTheWayDown() [with int i = 999]'
    turtles.cpp:9:44:   recursively required from 'bool isTurtlesAllTheWayDown() [with int i = 1]'
    turtles.cpp:9:44:   required from 'bool isTurtlesAllTheWayDown() [with int i = 0]'
    turtles.cpp:16:32:   required from here
    
    turtles.cpp:9:44: error: no matching function for call to 'isTurtlesAllTheWayDown()'
    turtles.cpp:9:44: note: candidate is:
    turtles.cpp:6:6: note: template<int i> bool isTurtlesAllTheWayDown()
    turtles.cpp:6:6: note:   substitution of deduced template arguments resulted in errors seen above
    
    real    0m0.131s
    user    0m0.113s
    sys     0m0.009s
    
    [postgres@sofa tmp]$ time gcc turtles.cpp -o turtles -std=c++11  -ftemplate-depth=9999
    turtles.cpp:9:44: error: template instantiation depth exceeds maximum of 9999 (use -ftemplate-depth= to increase the maximum) substituting 'template<int i> bool isTurtlesAllTheWayDown() [with int i = 9999]'
    turtles.cpp:9:44:   recursively required from 'bool isTurtlesAllTheWayDown() [with int i = 1]'
    turtles.cpp:9:44:   required from 'bool isTurtlesAllTheWayDown() [with int i = 0]'
    turtles.cpp:16:32:   required from here
    
    turtles.cpp:9:44: error: no matching function for call to 'isTurtlesAllTheWayDown()'
    turtles.cpp:9:44: note: candidate is:
    turtles.cpp:6:6: note: template<int i> bool isTurtlesAllTheWayDown()
    turtles.cpp:6:6: note:   substitution of deduced template arguments resulted in errors seen above
    
    real    0m2.647s
    user    0m2.542s
    sys     0m0.096s
    
    [postgres@sofa tmp]$ time gcc turtles.cpp -o turtles -std=c++11  -ftemplate-depth=99999
    turtles.cpp:9:44: error: template instantiation depth exceeds maximum of 99999 (use -ftemplate-depth= to increase the maximum) substituting 'template<int i> bool isTurtlesAllTheWayDown() [with int i = 99999]'
    turtles.cpp:9:44:   recursively required from 'bool isTurtlesAllTheWayDown() [with int i = 1]'
    turtles.cpp:9:44:   required from 'bool isTurtlesAllTheWayDown() [with int i = 0]'
    turtles.cpp:16:32:   required from here
    
    turtles.cpp:9:44: error: no matching function for call to 'isTurtlesAllTheWayDown()'
    turtles.cpp:9:44: note: candidate is:
    turtles.cpp:6:6: note: template<int i> bool isTurtlesAllTheWayDown()
    turtles.cpp:6:6: note:   substitution of deduced template arguments resulted in errors seen above
    
    real    3m22.952s
    user    3m21.085s
    sys     0m0.793s
    

    Naïevely extrapolating1 suggests at least 3+ months to (fail to) compile 4294967296.


    1 https://www.google.co.uk/search?q=(4294967296%2F99999*3)+minutes+in+days

  • (disco) in reply to PJH

    No wonder it takes so long. If no inlining would be done, the executable would be in tens of gigabytes. Still, gonna do some more testing tomorrow. On short int.

  • (disco) in reply to Gaska

    short unsigned int. The signedness means technically, instantiating your template causes UB. Probably would come out working the way you expect, but using unsigned will make sure.

  • (disco) in reply to EvanED

    On x86, it is de facto implementation-defined rather than undefined - and implementations define it as "treat signed overflow the same as unsigned overflow".

  • (disco) in reply to Gaska

    That's probably true during template instantation, but considering what goes on in optimization with normal code (where it is most definitely not treated as defined, wraparound behavior) I don't see why you'd pick the one with actually-defined behavior when it doesn't really have any downsides for your experiment. Sort of a "I type ++i for iterators because maybe, in some cases, the optimizer will be dumb even though it probably won't" kind of thing.

  • (disco) in reply to EvanED
    EvanED:
    *Probably* would come out working the way you expect,

    I'd be very surprised if it didn't come out working the way I expect...

    I'd fully expect it to not get as far as compiling, and I'd be very surprised at any other outcome...

  • (disco) in reply to EvanED
    EvanED:
    considering what goes on in optimization
    This experiment **won't** work with optimizations enabled. Template function calls will get inlined, impossible paths will be cut, tail call optimization will kick in, and the only leftover will be infinite loop doing nothing. -O0 is the only option (pun not intended).

    Anyway, the reason why I wrote short int and not unsigned short int is because it was 1AM.

    PJH:
    I'd fully expect it to not get as far as compiling
    Why? The code is valid C++. The only reason why it doesn't compile is because of compiler limitations. It will overflow stack and crash at runtime, however - but that's too just platform limitations and not because of invalid code.
  • (disco) in reply to Gaska
    Gaska:
    The code is valid C++.

    Really?

    Let me know which section of the C++ standard allows for ∞ to be stored in an int, and I may concede the point.

  • (disco) in reply to PJH

    doesn't it only specify the minimum size for an int? No maximum, therefore ℵ0 is an acceptable value

  • (disco) in reply to Jaloopa
    Jaloopa:
    doesn't it only specify the minimum size for an int? No maximum, therefore ℵ0 is an acceptable value
    <limits.h> specifies the largest (positive and negative) values an int may hold.

    [lib.numeric.limits] describes has_infinity and indicates that it is true only for floating point types (and the only other specialisation given is for bool, for which it is, obviously, FILE_NOT_FOUND.)

  • (disco) in reply to PJH

    I stand corrected. Luckily, I've never had to delve too deep into the inner workings of C++

  • (disco) in reply to Jaloopa
    Jaloopa:
    I stand corrected. Luckily, I've never had to delve too deep into the inner workings of C++

    The Standard's aren't exactly riveting reading....

  • (disco)
    PJH:
    Let me know which section of the C++ standard allows for ∞ to be stored in an int, and I may concede the point.
    §4.7.3 "If the destination type is signed, the value is unchanged if it can be represented in the destination type (and bit-field width); otherwise, the value is implementation-defined."
  • (disco) in reply to PJH

    limits.h is only valid for the architecture it's compiling for. there are different values for 32, 64 and 128 bit compilers (yes we do have a few 128 bit processors. they cost as much as a vintage mustang in mint condition but they do exist)

    so one could expand that to a thoretical infinite bit computer....

    of course we probably couldn't build the sucker, but we can theorize about it and, more importantly, implement a C compiler for it.

  • (disco) in reply to accalia

    You don't have to theorize for it.

    You just have to reserve a value to represent infinity, then create the rules for how it interacts with other values.

    infinity +/- (finite int value) = infinity.

    http://msdn.microsoft.com/en-us/library/system.double.positiveinfinity(v=vs.110).aspx

  • (disco) in reply to xaade

    floating point numbers make provisions for non number values in their ISO spec. integers don't. they are simply numbers stored as 2's compliment values (for signed numbers) there is no "not a finite number" value there.

    i can look up chapter and verse if you want, but it's lunch hours. i'd much rather work on sockbot.

  • (disco) in reply to PJH
    PJH:

    [postgres@sofa tmp]$ time gcc turtles.cpp -o turtles -std=c++11  -ftemplate-depth=99999

    PJH:

    real    3m22.952s

    Nearly 3 and a half minutes to count to about 100k? That's a crappy scripting language there. Why not switch to something faster? Like Ruby… ;-)

Leave a comment on “Brick by Brick”

Log In or post as a guest

Replying to comment #:

« Return to Article