yeah.. I am a bit embarrassed I missed it, I have used arguments.callee
before but never to generate that syntax. An elegant solution, but I agree a
little cryptic.

On Fri, Oct 3, 2008 at 11:59 AM, Tom Occhino <[EMAIL PROTECTED]> wrote:

> 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 <
>> [EMAIL 
>> PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1142175&i=0>
>> > 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<http://n2.nabble.com/confused-with-core.js-tp1142162p1142175.html>
>> Sent from the MooTools Users mailing list 
>> archive<http://n2.nabble.com/MooTools-Users-f660466.html>at Nabble.com.
>>
>
>
>

Reply via email to