Redefine post(), why doesn't this work?


    Nov 25 2013 | 8:08 am
    In an attempt to create a post function that appends a newline at every call, I came up with this:
    var global = this;
    var __post = post;
    var post = function(){
    var args = Array.prototype.slice.call(arguments, 0);
    __post.apply(global, args.concat('\\n'));
    };
    This doesn't work. It generates the following error:
    Javascript TypeError: __post is undefined, line 12
    It does work as long as you use a different name for the post function, like this:
    var log = function(){
    var args = Array.prototype.slice.call(arguments, 0);
    __post.apply(global, args.concat('\\n'));
    };
    Looks like it's not really that __post is undefined, but that the assigned reference to post becomes undefined.
    Just out of curiosity, why won't this work?