Thank you for the insight, Thomas. I think for my purposes, for what
that's worth, I will continue to use proto and manage the lib interop
issues as I have been. At least, anyway, until I have some time to
really put Dojo to the test. Good luck, Martin (and anyone else trying
to do this stuff in an open environment)... it would be interesting to
hear what comes of your situation, please keep us posted.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Thomas Fuchs
Sent: Wednesday, January 04, 2006 2:52 AM
To: [email protected]
Subject: Re: [Rails-spinoffs] Re: Status of Prototype

Am 04.01.2006 um 00:54 schrieb Werner Punz:
> Well that is the problem the alteration of object also broke the  
> for loop on the Array, because the basic prototype structures of every
> object in the system were altered.
>
> Similar issues could arise at other parts of the lib,
> the already fixed iterate over object (and therefore iterate over  
> everything javascript object related) bug just was the most  
> prominent showcase of those issues.

Heya,

The problem here is really not Prototype extending JavaScript built- 
in objects.

JavaScript is a dynamic language and you're not forbidden from  
extending the
built-ins to become more programmer-friendly.

It really all boils down to one thing (let the namespaces aside for  
now):

The for-in loop.

This is a language construct that iterates over all properties of an  
object.
Because JavaScript is a dynamic language where you can add/change
Object prototypes at all times, this construct doesn't guarantee the  
kind of
properties which are returned.

According to the ECMAScript Language Specification:
"Enumerating the properties of an object includes enumerating  
properties of its prototype".

So the problem is that the for-in loop is just not used with that in  
mind when
it's called upon for stuff like iterating over the elements of an array.

(sadly, the JavaScript "DontEnum" attribute can't be set manuall,
so it can't be used to mask/hide individual properties (like the
addtional functions on the Object prototype):
"DontEnum: The property is not to be enumerated by a for-in  
enumeration").

IMHO, trying to not to use extensions for built-in objects (where  
they really make sense,
see Prototype's Enumerables) to avoid errors because of "misinformed  
programming"
in other libraries is not using the JavaScript language for what it is.

Note that even Brendan Eich, the "father of JavaScript" recommends  
that if
you want extensions on built-in objects, than just do it (as it's  
meant for that).
(He also acknowledges the for-in loop problem and is in favor of  
adding something to the next Version
of JavaScript so you can define DontEnum properties, that won't show  
in for-in loops.)

-Thomas
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

The information transmitted in this electronic mail is intended only for the
person or entity to which it is addressed and may contain confidential,
proprietary, and/or privileged material.  Any review, retransmission, 
dissemination or other use of, or taking of any action in reliance upon,
this information by persons or entities other than the intended recipient
is prohibited. If you received this in error, please contact the sender and
delete the material from all computers.

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to