On Jun 28, 2006, at 9:03 PM, [EMAIL PROTECTED] wrote:

>
> I took a look at jQuery.  I saw this in the doco:
>
> "Loading jQuery first, then Prototype, will cause your code to break -
> as a reminder, jQuery throws an exception saying: "You are overwriting
> jQuery, please include jQuery last."
>
> Bob, am I to assume that this is what you mean by other libraries
> "mangling" object.prototype?  ;)

Actually in this case I'm pretty sure it's a global namespace  
conflict. jQuery and Prototype both need a global $ function in order  
to operate. I think the jQuery guys pray that their function is a  
superset of what Prototype's does, but that's probably not the case  
anymore now that Prototype's $ function does more crap.

MochiKit will export a global $ function, but it doesn't need it to  
be global in order to function properly (in that case, it's actually  
called getElement internally). The exports are merely a convenience  
to make your code shorter. One of the reasons that MochiKit is larger  
than the hackier libraries like Prototype is that it is very  
defensively programmed and requires lots of fully qualified  
references to other parts of itself.

MochiKit could be (somewhat dramatically) shorted by using closures  
instead, but closures don't allow for hot-patching. Right now, if you  
find a deficiency in a MochiKit function or would like to add tracing  
or something, you can simply patch in your own version at runtime. If  
a closure was used, you'd never be able to acquire a reference to the  
activation objects that contain the internal references.

For example:

<script type="text/javascript" src="MochiKit/MochiKit.js"></script>
<script type="text/javascript">
/*
    Replace map with a tracing version for debugging this page. Even  
MochiKit's
    internal usage of map will be affected by this change!
*/
// use a function here so we don't pollute the global namespace with  
"oldMap"
(function () {
        var oldMap = MochiKit.Base.map;
        MochiKit.Base.map = function () {
                log('oldMap being called: ' + repr(list(arguments)));
                return oldMap.apply(arguments);
        };
})();
</script>

-bob


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to