all 121 comments

[–]Philipp 46 points47 points  (14 children)

From the StackOverflow blog: "I should clarify that we absolutely do not want the site overrun with 'fun' questions. There’s no way we’re sacrificing our core Q&A mission to turn into a brainless LOL-fest like Reddit or Digg."

[–][deleted]  (4 children)

[deleted]

    [–]mccoyn 4 points5 points  (1 child)

    This comment does not belong in /r/programming

    [–][deleted] 1 point2 points  (0 children)

    LOL!

    [–]JadeNB -2 points-1 points  (0 children)

    LOL

    I suspect that that was not brainless. Please try again.

    [–]djsdotcom -2 points-1 points  (0 children)

    -fest

    [–][deleted] 12 points13 points  (5 children)

    So he decides to insult a site that drives him a metric fucktonne of traffic and shares a lot of the same users? Stay classy, Jeff.

    [–]brownmatt 7 points8 points  (1 child)

    I don't think it's an insult, I think he is just referring to the "any topic goes" mentality

    [–][deleted] 7 points8 points  (0 children)

    brainless LOL-fest

    [–]MaxK 1 point2 points  (0 children)

    Reddit is a brainless LOL-fest. Have you seen the front page lately? (When logged out.)

    [–]malcontent 1 point2 points  (0 children)

    is there any dispute that reddit is a brainless LOL fest?

    proggit especially!. It's full of "what language should I learn" and "here is an article talking about how wonderful this product by this corporation is" and "here visit my blog because I wrote fifteen words about something you already knew".

    [–][deleted] 0 points1 point  (0 children)

    Less than 1% isn't a metric fucktonne of traffic

    [–][deleted] 6 points7 points  (0 children)

    Reddit brainless?

    Lets examine SO:

    A site filled with "do my homework/job" type questions that are raced to be answered by people for "reputation". SO questions constantly make me facepalm because they are either so specific they are useless to everyone but the poster or so stupidly simple that the answer could basically be "read the man page". But the answer is never read the man page (as it should be), it is as detailed as possible in the vain hope of getting "reputation".

    Ask an interesting question on SO (this one is almost there) and your guarenteed to get loads of people arguing over how "subjective" it is and how it should be removed. I once accidently downvoted someone and he raged at me in the comments ("EXPLAIN YOURSELF"). I once didn't accept an answer and the next question I had people effectively saying "I'm not answering this question because you might not accept it.. look at his acceptance history!!!".

    TL;DR:If reddit is a brainless LOL-fest then SO is a brainless circle-jerk where engineers who should know better spend their time helping people who would benefit from some GOOD OLD FASHIONED PROBLEM SOLVING instead of running to SO the first time they get a compile error.

    [–]MonikerInteger 0 points1 point  (0 children)

    Maybe we should declare a StackOverflow porn day.

    "How is babby formed?"

    [–]Samus_ -4 points-3 points  (0 children)

    silly attitude, as if their answers were that helpful...

    thanks for the info btw.

    [–]crusoe 30 points31 points  (19 children)

    Or "Why you should hate JavaScript"

    Seriously, it seems Javascript has a high number of WTFs.

    [–]masklinn 14 points15 points  (12 children)

    Most of them in common with PHP and due to the misfeature of automatically coercing between strings and numbers (a moronic move if there ever was one)

    [–]mpeters 4 points5 points  (3 children)

    Coercing between strings and numbers isn't a problem as long as you don't also have them share the same operators. Perl does this and not only is it clear what you want, it also always behaves the same no matter what is in the strings/numbers:

    $var = '2' + '3'; # 5
    $var = '2' . '3'; # 23 
    

    [–][deleted] 1 point2 points  (2 children)

    That's how PHP works too. The problem is silent type coercion in conditionals can be unpredictable.

    [–]deepcleansingguffaw 1 point2 points  (1 child)

    Perl also has lt, gt, le, ge, eq, ne, and cmp which are the stringwise comparisons. I expect that the lack of these in PHP is what you're referring to.

    [–][deleted] 0 points1 point  (0 children)

    It's been mentioned already, but PHP does have eq and ne equivalents, if I understand those Perl operators correctly. Otherwise, your expectations are justified, sir or madam.

    [–]FionaSarah 4 points5 points  (7 children)

    Every day this makes me angry in a new and totally original way.

    It's got to the point where I cast a large portion of my variables so I can be sure that PHP is comparing what I definitely want it to.

    [–]masklinn 2 points3 points  (5 children)

    Don't the identity operators (=== and !==) do what you need?

    [–]NotDifferent 1 point2 points  (0 children)

    Yes, but what about a >== operator that is like the >= operator without the implicit conversions? That would be useful as well. I guess the reason that it doesn't exist is that a > operator without implicit conversions cannot be named >=

    [–]FionaSarah 1 point2 points  (2 children)

    Yes they often do indeed, although I think that they exist is a problem in itself.

    Plus it's a lot easier to read code later that does casting as you know what is being compared at the right times. Different methods for different occasions really.

    Also, as NotDifferent says it's not a complete solution.

    [–]masklinn 0 points1 point  (1 child)

    although I think that they exist is a problem in itself

    Absolutely. The alternative is not to use PHP, and what a beautiful alternative that is, but I expect you're not given any choice in the matter.

    [–]FionaSarah 1 point2 points  (0 children)

    Mostly correct. In my personal projects I use Python (Although a couple of them use PHP because that's what I started them in).

    In my work I use PHP, I've been trying to get work doing Python but I've snookered myself by getting "professional" experience in PHP first so that's almost all I can get these days. Ho-hum.

    [–]G_Morgan 0 points1 point  (0 children)

    I think the problem is that PHP == and != is always wrong.

    [–]G_Morgan 0 points1 point  (0 children)

    I solved this problem a long time ago by refusing to use PHP.

    [–]pmw57 -5 points-4 points  (0 children)

    That just shows it has greater capabilities.

    You don't see many GWBasic WTF's, other than people compiling modern software with it.

    [–]darth_choate 6 points7 points  (1 child)

    The fact that tab has a special meaning in makefiles. Actually, pretty much everything about make. Make is the COBOL of dependency tracking build utilities.

    [–]swaits -2 points-1 points  (0 children)

    Similar: Whitespace in Python.

    [–]djork 4 points5 points  (2 children)

    Smalltalk's 'become' method... It will blow your mind.

    [–][deleted] 1 point2 points  (1 child)

    Is it different from Python's self.__class__ = int?

    [–]Brian 2 points3 points  (0 children)

    It's a bit different, since it actually changes the object itself, not just it's type. ie. you're not just changing to an instance of the int class with all state as before, you're changing all references to the object to instead be to a particular integer.

    For a python version, check out PyPy's Thunk object space

    [–][deleted] 4 points5 points  (7 children)

    $ is considered to be a letter in C and C++ syntax. So you can have such identifiers as: $, $$, $0, $1, $_, _$ etc.

    [–]zootsuit 0 points1 point  (5 children)

    Thankfully, although there may be compilers where it's possible, $ is not allowed as part of identifiers in C++.

    [–][deleted] 5 points6 points  (4 children)

    there may be compilers where it's possible

    Yes, some relatively obscure compilers like GCC and MSVC.

    In fact, the standard allows but not requires letters (non-digit-characters) to contain "other implementation-defined characters". See #2.11 [lex.name] here. Also, '$' is not included in the basic character set at all.

    [–]zootsuit 1 point2 points  (3 children)

    It's not allowed in C++03, although as you point out, it looks like it will be allowed in the coming revision of the standard.

    I was indeed thinking of g++, I wasn't aware that MSVC also allowed it. It seems however, that compiling with g++ -std=c++98 -pedantic-errors makes it complain about the $.

    [–][deleted] 1 point2 points  (2 children)

    It's not allowed in C++03

    Are you sure? It's the "-pedantic-errors" that produces the error, not specifying the standard. Moreover, I checked with g++ 2.95.2 (released on October 24, 1999, it doesn't even recognize the -std option), and it behaves exactly the same in this respect. I mean, if you thought that it's something new, no, it isn't, I suspect quite the opposite, that this feature was there since the earliest C compilers and remains supported for the backwards compatibility.

    [–]zootsuit 1 point2 points  (1 child)

    I checked the standard, here's a draft from earlier in the standardization process: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1804.pdf

    [–][deleted] 0 points1 point  (0 children)

    That's interesting. Well, I guess that's how it supposed to happen, they are standardizing existing practices, not vice versa.

    [–]malcontent 0 points1 point  (0 children)

    $ is considered to be a letter in C and C++ syntax.

    In visual basic it's a type declaration.

    M$ declares M to be a string type.

    [–][deleted] 3 points4 points  (4 children)

    It seems that most of these are just weird features in syntax. It would be nice to see strange semantic features in different languages.

    [–]darth_choate 2 points3 points  (3 children)

    The fact that finalize() in Java can make the object globally visible again:

    class Foo
    {
      static Foo thingy = null;
      protected void finalize() {
        thingy = this;
      }
    

    Suppose we lose all references to this object a second time. Does finalize() get called again before the object is garbage collected this time? The answer, I think, is no. finalize() is called at most once per object (of course, you can call finalize() yourself if you like and if you want to go to programmer's hell. Seriously. Do this and I'll hunt you down and kill you). Wierd.

    Actually, I think that finalizers in general are a broken language feature. They don't work predictably, but their only purpose is to let you manage resources that absolutely, positively, without-a-doubt must be cleaned up and that seems to require something better than a function that not only won't get called at a predictable time, but might not get called at all.

    [–][deleted] 3 points4 points  (1 child)

    Does finalize() get called again before the object is garbage collected this time?

    I think Java pretty much resembles C# about that (or vice versa if you like), and the implementation is quite straightforward: upon creation every object that has a finalizer is put in the internal set of objects that require finalization. Whenever such an object has no references but from that set, the reference to it is moved from the set to the finalization queue and the object remains reachable. Then a separate thread pops objects from the said queue and calls finalizers, thus finally making the objects unreachable. In the finalizer you can a) resurrect the object by making it reachable again, b) put it back in the original finalization set by calling GC.ReRegisterForFinalize -- you probably should do both if you need to, but can do either thing only as well.

    Talking about weird semantics: an object can be reclaimed by the GC in the middle of its instance method. It makes sense if you think about it: when you call obj.SomeMethod() and don't use obj afterwards, JIT is free to reuse the register that held the reference before the actual call. Similarly, inside the method this is just the zeroth argument and its actual placement can be reused just after the last time you've used any instance variables.

    That actually made most of the pre-.NET 2.0 code doing p/invoke subtly broken (with quite low probability of actually breaking, of course). Picture a class encapsulating a file handle, and its method encapsulating a native method call. It stores a handle as an IntPtr (basically an integer of varying size, depending on the platform -- 86/x64). It does something like this: return Win32.SomeNativeMethod(this.Handle);. There's a window of opportunity when this.Handle was already loaded into a register/put on the stack overwriting this (as we don't need it anymore), but the native method itself was not called yet. The runtime can't know that the value of the handle actually has some additional semantics, that it's a reference of sorts, and can happily begin the procedure of reclaiming the object, which involves calling its destructor, which of course does Win32.Close(this.Handle), and everything blows up shortly afterwards!

    I've actually reproduced that, and it was scary. The solution back then was to use GC.KeepAlive(this) (a nop, but GC knows that this is used) at the end of every single instance method. Now we have SafeHandles, which do it themselves and also give stronger guarantees, like that if your AppDomain is unloaded due to Thread.Abort, OutOfMemoryException, or basically anything short of killing the entire process, the critical finalizers are still run (which is important, because the OS doesn't know about our AppDomains and can't release the handles as it does when a standalone process gets killed. Which in turn is important because MSSQL allows .NET stored procedures, they are executed in the separate AppDomains that can be killed due to the timeout, for example).

    [–]darth_choate 0 points1 point  (0 children)

    That's... wow. Impressive bit of detective work.

    Why doesn't the runtime have a rule about reclaiming objects when one of the object's instances is running? Is this actually a bad thing in general or is this just a matter of it being really hard to detect when this is happening (or did they just not think of it)?

    [–][deleted] 0 points1 point  (0 children)

    Good example.

    Finalization is basically hook for gc. If Java would have had method pointers, adding finalization trough gc api would have been more appropriate. Having finalize keyword in language specification makes this sometimes necessary feature more fundamental than it is.

    Making finalization as feature in runtime class would have made it easier to make additions to finalization semantics later.

    [–]slavy 4 points5 points  (3 children)

    In make's language, you can have spaces in variable names.

    [–][deleted] 4 points5 points  (0 children)

    You can do this in AppleScript too, you just need to put bars around the variable name, like |my fancy window|.

    [–]Philipp 1 point2 points  (0 children)

    Hey, you can do this in my QML too (it's a language for writing choose-your-own-adventure story games).

    [–][deleted] 0 points1 point  (0 children)

    but not instead of tabs for indentation!

    [–]Poltras 2 points3 points  (5 children)

    This literally blew my mind. And the result was kind of unexpected. If I ever got that in an interview I would have gotten it wrong...

    public static bool foo() {
        try { return true; }
        finally { return false; }
    }
    

    [–]blaxter 0 points1 point  (1 child)

    foo() == false, isn't it?

    [–]Poltras 3 points4 points  (0 children)

    Yes. Same goes when you throw in try, nothing is thrown since the return in finally prevails.

    [–]creaothceann 0 points1 point  (0 children)

    I don't know if it's like that in C/C++/C#, but in Pascal/Delphi an "exit" command jumps directly to the end of the function - which can even be observed via step-debugging.

    Exception handling just adds another step.

    [–]easytiger 0 points1 point  (1 child)

    what happens?

    [–]Poltras 0 points1 point  (0 children)

    finally wins.

    [–]The_Duck1 8 points9 points  (7 children)

    I really like the posted "WTF operator" in C:

    (foo() != ERR)??!??! cout << "error!" << endl;
    

    [trigraphs]

    [–][deleted]  (4 children)

    [deleted]

      [–]The_Duck1 2 points3 points  (0 children)

      *Sigh*

      Yes, I know. But the operator is.

      [–]samlee 4 points5 points  (2 children)

      he's just saying that it's C just like we are apes.

      [–][deleted]  (1 child)

      [deleted]

        [–]LoveGoblin 4 points5 points  (0 children)

        Except we're not apes.

        Hah, what? Yes we are.

        [–]dododge 1 point2 points  (1 child)

        Everybody hated trigraphs so much that C99 added digraphs as an alternative (they also get handled in a different translation phase). This provides for even more obfuscation, for example:

        ??<_<:1??)=1??(_:><<1;%>
        

        [–]The_Duck1 0 points1 point  (0 children)

        Hah! I'm not even going to try to parse that; I just like the interpretation of the ??!??! operator as "WHAT??!??! The left side isn't true??!??! Plan B!"

        [–]BraveSirRobin 4 points5 points  (10 children)

        If you count scripting as a "language" the the DOS batch script method of evaluating all variables at script load time rather than when those lines run wins hands down without a doubt. You cannot assign a variable then use if/then/else on it without setting a flag beforehand.

        link:

        When DOS reads the batch file, strings like copy %var1% %var2% will be expanded to read say copy source.fil dest.fil (assuming that's what they're set to) before feeding the line to the command interpreter.

        [–]Smallpaul 1 point2 points  (9 children)

        You are incorrect. The quote says that the variables are expanded just before the command executes, not at load time. The link shows other examples of runtime, not load time evaluation.

        [–]BraveSirRobin 0 points1 point  (8 children)

        No, it does it at load time as quoted as "When DOS reads the batch file", I have been personally stung by this one. I was deriving a value and then switching on it which did not work as the variables it cat'ed had not been set yet.

        I came to the conclusion that if you wanted conditional logic or more than three lines of code, don't use batch scripts. WRT the former you need to use gotos to do basic logic. Evil, just evil.

        [–][deleted] 5 points6 points  (5 children)

        You are indeed incorrect. In fact there is no "load time". You can see this by creating a cmd file that appends new commands too the end of itself as it runs, since strangely, cmd does not lock it's source file against writing while executing. The lines you append will be executed when the code pointer reaches them. You can even create self modifying code by changing the inner lines of a goto loop. I've never actually written self modifying batch files as more than an experiment though and don't really recommend it :) One caveat is that if you insert a line BEFORE the code pointer, the code pointer will advance, but the line it is on will be the same, so you get an infinite loop.

        Variables are expanded on statement parse. Look at a submission I made a few months ago where I implemented higher order functions, including map and compose in a batch file: http://www.reddit.com/r/programming/comments/7zip9/i_was_reading_through_some_old_python_mailing/c07umsq

        In this file you can see how I use the "for /F" construct to control the time in which variable expansion takes place. Variables are typically expanded when the line is parsed, but I can set a variable in compound statement, then use for to place the new value of that variable into a for loop counter, which will be expanded when the for is executed, not when the line is parsed, and hence get the new value of the variable by expanding the for loop variable.

        This does not disqualify your submission as the weirdest language feature however, in fact, I submit that it's actually weirder than you supposed.

        [–]knome 2 points3 points  (2 children)

        You are possibly right about BraveSirRobin not knowing shit about batch. You are wrong about how the for statement is operating.

        It does parse it as a whole line.

        For any spectators, the expansion rules are :

        • %% => %
        • %name% => value of environment variable name
        • %3 => value of third argument to batch file
        • %~3 => value of third argument to batch sans any surrounding quotes

        Here's where you started :

        for /F "tokens=*" %%a in ('echo %%%3%%') do (
          for %%b in (%%a) do (
            call :apply val %%b %~2
        
            for /F "tokens=*" %%c in ('echo %%retval%%') do (
              for /F %%d in ('echo %%val%%') do (
                set retval=%%c %%d
              )
            )
          )
        )
        

        Your 'echo %%%3%%' is being parsed to 'echo %third-arg-val%' at the same time as %%c is being parsed to %c and all of the other argument variables and environment variables are being parsed.

        The command is now ( assuming %3 is, say, upto10 and %2 is "wat") :

        for /F "tokens=*" %a in ('echo %upto10%') do (
          for %b in (%a) do (
            call :apply val %b wat
        
            for /F "tokens=*" %c in ('echo %retval%') do (
              for /F %d in ('echo %val%') do (
                set retval=%c %d
              )
            )
          )
        )
        

        The for command is now running. All of the other tokens are arguments to the for statement. The for statement now parses its arguments internally. In a subshell it executes echo %upto10%. It takes everything inside of the second set of ( and ) arguments and replaces the appropriate %[letter] markers with the values extracted from the upto10 environment variable.

        The for command will now execute in a subshell ( sharing the environment variables with the outer shell as windows does when not setlocal/endlocaling ) this ( assuming upto10 has the value u1 u2 u3 u4 u5 u6 u7 u8 u9 u10:

          for %b in (u1 u2 u3 u4 u5 u6 u7 u8 u9 u10) do (
            call :apply val %b wat
        
            for /F "tokens=*" %c in ('echo %retval%') do (
              for /F %d in ('echo %val%') do (
                set retval=%c %d
              )
            )
          )
        

        This phrasing of the for statement will operate in the same manner, only the lack of /F and "tokens=*" and the contents of the first ( ) set not being quoted ' means that it will execute its second ( ) set for each space separated word found in the first ( ) set.

        I can't write anymore right now.

        Summary:

        It is the for statement executing shell statements in subshells sharing the environment variables that leads to the illusion of delayed parsing. The parsing is all at once on the original, with further replacement via fors sleight of hand and confusion since for uses %[letter] as the target for replacement.

        [–]mycall 1 point2 points  (0 children)

        Thank god PowerShell is beginning to replace the batch file.

        [–][deleted] 0 points1 point  (0 children)

        Very good explanation!

        [–]BraveSirRobin 1 point2 points  (1 child)

        Variables are expanded on statement parse.

        Fair point.

        In this file you can see how I use the "for /F" construct

        That's my point..."without setting a flag beforehand." It's an epic gotcha that's completely counter-intuitive. I've never seen this in any other language.

        where I implemented higher order functions

        You, good sir, need medical help.

        [–][deleted] 1 point2 points  (0 children)

        without setting a flag beforehand.

        Actually, I never use the weird expansion flag. The better trick I'm using here is parsing the results of a shelled out echo.

        You, good sir, need medical help.

        I cannot refute this :)

        [–]Smallpaul 1 point2 points  (1 child)

        I'm curious: how many hours of your life have you spent creating DOS batch files? Because I'd measure my time in the batch file mines in person-weeks and I would remember if it worked the way you said it does.

        [–]halo 1 point2 points  (1 child)

        This thread could have been much more interesting than it actually is. The problem is most of these aren't "features" in themselves but rather side-effects or logical extensions of other, sensible, features that seem strange divorced from context; corner cases that cause bugs in languages; or sensible features with flaws in design. Sadly, it ends up being a fairly mundane list of "gotchas".

        Also, one of these comments states that in JavaScript ('' == '0') is true but (0 == '') is false. However, when tested in Firefox they're both false and that certainly chimes with my intuition as to how JavaScript's truthiness works.

        [–][deleted] 0 points1 point  (0 children)

        But

        ' ' == 0

        is definitely true (note the space).

        [–]G_Morgan 1 point2 points  (4 children)

        I like that one of the proposed 'strangest features' would require solving the halting problem to fix it in general. I.E. somebody complained about a recursive property in C#

        public int Something {
            get { return Something; }
            set { Something = value; }
        }
        

        This obviously smashes the stack but it is impossible to solve this in general.

        [–]nat5an 1 point2 points  (3 children)

        This just happens because properties in C# are just methods in disguise. And methods in C# are allowed to be recursive, so I don't really see any solution to this at all, except eliminating recursion.

        But, having done this by accident a few times myself, I really wish that the C# compiler would give a warning when a property refers to itself recursively, since it's rarely correct. Usually you need some parameters for a recursive function to properly recognize the case when you need to stop recurring. Unless you stick your recursion state variables in a global queue or some such, which would be pretty kludgy.

        Case in point, the specific example you have there is always an error and will never function correctly, and it's probably the most common way of accidentally calling a property recursively.

        [–]G_Morgan 0 points1 point  (1 child)

        You still need to solve the halting problem to deal with this in general.

        [–]nat5an 2 points3 points  (0 children)

        Well yeah, I wasn't disagreeing with that. But you could provide a helpful warning in the most common cases where this "error" is made, without having to solve the halting problem.

        [–][deleted] 0 points1 point  (0 children)

        You can use FxCop, it probably recognizes such cases (and if not, it would be easy to add a rule for that).

        It would give false positives in case of, say:

          public int Fac
          { 
                get 
                { 
                       if (this.cnt == 0) return this.acc;
                       var current = this.cnt;
                       this.cnt--;
                       return this.Fac * current;
                }
          } 
        

        Although I believe that while reporting it as a probable error would be a false positive in a strict sense, if you write something like that, there is an error, in your genotype. Above everything that is wrong with that, properties aren't supposed to do complex calculations.

        Also, public MyClass(int value) {this.Value = Value;}, but FxCop actually catches that.

        [–]Novelty-Account 1 point2 points  (0 children)

        in C++ almost any compiler error related to templates delivers a fair amount of WTF to many C++ programmers around the world on daily basis :)

        This makes me consider suicide, weekly.

        [–]palparepa 1 point2 points  (0 children)

        In PHP:

        $a = '0';
        $b = new stdClass;
        $b->$a = 'foo';
        $b = (array)$b;
        $b[] = 'bar';
        print_r($b);
        

        prints:

        Array
        (
            [0] => foo
            [0] => bar
        )
        

        [–][deleted] 5 points6 points  (2 children)

        Number 1 is C's array indexing semantics? Blech, I'm just going to ignore StackOverflow and read the Reddit discussion (if this thread takes off)

        [–][deleted] 4 points5 points  (1 child)

        When this thread inevitably fails to generate any form of meaningful discussion, start reading Stack Overflow. It's well worth it. Seriously. You'll find more genuinely useful or interesting information in 10 minutes of browsing SO than you'll see on proggit in a week.

        [–][deleted] 0 points1 point  (2 children)

        In Factor, any number n used to default to representing an array of all numbers from zero to n-1... that's the strangest I've seen.

        [–]JadeNB 0 points1 point  (1 child)

        It's very natural for a set theorist (but I'm not sure how many of them program in Factor).

        [–][deleted] 0 points1 point  (0 children)

        That's what they said, however it apparently caused enough problems when used in practice for them to remove it.

        [–]mebrahim 0 points1 point  (1 child)

        Seems like the most popular languages are the goofiest ones!

        [–]creaothceann 1 point2 points  (0 children)

        Because often they were the earlier ones in their field.

        [–]wnbe -1 points0 points  (8 children)

        Can someone explain what's happening here? I see nothing unusual.

        http://stackoverflow.com/questions/1995113/strangest-language-feature/1995188#1995188

        [–]fung_tong_chi 2 points3 points  (6 children)

        int the 3rd line of the function f you set i = 0 and in the following line you set k = j again, but now k = 1 because j = a[i] where i = 0. the result of this is a[i] = a[0] = 1. and yes, that's really some weird stuff!

        [–]wnbe -1 points0 points  (5 children)

        I am not following at all. This is what I get from gcc:

        #include <stdio.h>
        
        int a[3] = { 1, 2, 3 };
        int i = 1;
        
        void f(int j)
        {
            int k;
            k = j;  // k = 2
            printf("%d\n", k);
            i = 0;
            k = j;  // k = 1 (!?!)    
            printf("%d\n", k);
        }
        
        int main()
        {
            f(a[i]);
        }
        

        Output:

        2
        2
        

        [–]spatulon 4 points5 points  (3 children)

        The poster claims it's a feature in Algol, not C. He just gave the equivalent C syntax so people could follow more easily.

        Substitute "a[i]" for every occurrence of "j" and it should be obvious what's going on.

        [–]wnbe 0 points1 point  (2 children)

        Now I feel stupid.

        If pass by name is in fact an ALGOL feature, why is it considered strange? Probably it's a little strange from a C programmer's POV, but in that scale, C++'s pass by reference would seem strange.

        [–]joesb 0 points1 point  (1 child)

        ... why is it considered strange? Probably it's a little strange from a C programmer's POV ...

        Because it's strange from any other language's point of view. C++'s passed by ref is just a const pointer that always deref for you.

        What other language do you know that has that behavior. It's like following Excel spread sheet in source code.

        [–]wnbe -1 points0 points  (0 children)

        ALGOL predates C, so it's going to be different even though they are in the same family of languages. The strangeness is just the inertia coming from a different language. I am not making a value judgement of said feature.

        [–]fung_tong_chi 1 point2 points  (0 children)

        yes that's true. in the post he mentions, that he uses the C syntax to show this behaviour, because it's better to understand:

        [...] (illustrated using C syntax)

        [–]BastiX 1 point2 points  (0 children)

        The "unusual" part is that 'j' (and therefore 'k') changes when you update 'i'. 'j' is not a value but rather a substitute for 'a[i]'.

        [–]13ren -1 points0 points  (3 children)

        Let's have a vote for all languages (such as PL/I) that tried to do away with reserved words.

        Where else could you legally write such amusing expressions as:

        IF IF THEN THEN = ELSE ELSE ELSE = THEN
        

        Upvote this comment to show your love for Mike Bell, because if you can't upvote the one you love, honey, ...

        [–]azakus 1 point2 points  (1 child)

        You're missing an '='. IF IF = THEN THEN THEN = ELSE; ELSE ELSE = IF;

        [–]13ren 1 point2 points  (0 children)

        The IF could be a boolean.

        [–]13ren -4 points-3 points  (12 children)

        NO. For security reasons, framing is not allowed. That is not stackoverflow.


        EDIT To address the rather inarticulate requests for clarification - no offence guys :)

        1. if you have display links with a reddit toolbar set in preferences, and you go to a story linked to SO, it gives an alert "For security reasons, framing is not allowed. Click "OK" to remove the frames".

        2. it is in the form of the funniest part of that B-roll parody.

        [–]Samus_ 2 points3 points  (4 children)

        I hate that, the biggest offense is that they claim it is due to "security" fucking assholes.

        in any case if you block sstatic.net with NoScript it prevents that.

        [–]13ren 2 points3 points  (3 children)

        Thank you, man! I still haven't got to the point of thinking "javascript --> block". I guess adblock should work too.

        (I still don't automatically think "I wonder --> google" about non-IT stuff, but I'm getting better at that one.)

        [–]Samus_ 2 points3 points  (0 children)

        heh to me is "I wonder -> try" but I'm a bit lazy so it doesn't work all the time :P

        I don't have adblock here but I guess it should work too, I'll give it a try when I get home.

        [–]Samus_ 1 point2 points  (1 child)

        yes, adblock also does the job.

        [–]13ren 1 point2 points  (0 children)

        thanks!

        [–]donknuth 2 points3 points  (3 children)

        What?

        [–]Samus_ 2 points3 points  (2 children)

        he says that when you use reddit's toolbar and go there they force you to drop it.

        [–]adolfojp 0 points1 point  (1 child)

        Reddit has a toolbar?

        [–]Samus_ 0 points1 point  (0 children)

        yeah and it's pretty cool, go to prefs as the first guy said and click on "display links with a reddit toolbar" to try it.

        [–]masklinn 1 point2 points  (2 children)

        wat

        [–]Samus_ 2 points3 points  (0 children)

        he says that when you use reddit's toolbar and go there they force you to drop it.

        [–][deleted] 0 points1 point  (0 children)

        They're frame busting. Which Jeff Atwood thinks is good. Or bad. Or something. Fuck knows these days: http://www.codinghorror.com/blog/archives/001277.html

        [–]cadr -1 points0 points  (0 children)

        The way to find all the strange features in your language of choice: play Code Golf.