A lot of people found that behavior kind of cryptic... I cleaned it up for 1.2.1 with a single closure around all that stuff.

On Oct 3, 2008, at 11:12 AM, Nathan White wrote:

Ah... thanks guys... I totally missed that.. nice trick!

On Fri, Oct 3, 2008 at 11:04 AM, nutron <[EMAIL PROTECTED]> wrote:
If you look at the last line of the function, it returns arguments.callee. This is a pointer to the anonymous function. So the first call (with Array), calls the anonymous function. It then returns itself and so the second call does the same.


On Fri, Oct 3, 2008 at 8:01 AM, Nathan White <ml-user [EMAIL PROTECTED]> wrote: I feel comfortable with the internals of mootools for the most part and love reading the code. However in 1.2.0 there is a bit of code that perplexes me. I donno if I'm missing something or what. I figured I would ask for some help or clarification. I will note that in the nightly builds this code has been completely replaced with something that seems a bit more robust.

In the Core.js file line 103-108

(function(object, methods){
for (var i = methods.length; i--; i) Native.genericize(object, methods[i], true);
    return arguments.callee;
})
(Array, ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice', 'toString', 'valueOf', 'indexOf', 'lastIndexOf']) (String, ['charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'replace', 'search', 'slice', 'split', 'substr', 'substring', 'toLowerCase', 'toUpperCase', 'valueOf']);


I understand and recognize the anonymous function syntax (function() {})() but what I don't get is how the it appears the params are passed twice to the same anonymous function. The (Array...) followed by the (String...); doesn't makes sense to me. If I take this snippet of code out by itself modifying the internal function for generic debugging info it breaks. It handles the Array () fine but it gets to the String () and breaks.

I looked above in the code to see if I was missing some other closure but I didn't see anything.

Can anyone shed any light on this, and why it works?


The MooTools Tutorial: www.mootorial.com CNET Clientside: clientside.cnet.com

View this message in context: Re: confused with core.js
Sent from the MooTools Users mailing list archive at Nabble.com.


Reply via email to