if Enumerable was a class. But it isn't!
It's never going to be a class; it was supposed to be a module like in Ruby
language, which is then mixed in certain classes that define _each to get
enumerable goodness.
The Ruby analogy is not going very far anyway: If you change an
Enumerable
On Feb 11, 2008 2:35 PM, aljoscha [EMAIL PROTECTED] wrote:
Not so in the newer Hash implementation of prototype (starting with
1.5 something) - by manually copying all methods to the inheriting
classes this runtime flexibility was lost, probably as a trade off
for gaining an improved memory
Enumerable.addMethod(myFunction) that takes care of all the classes
that implement or extend it.
Hmmm. We have Class#addMethods() already which makes exactly what
you're talking about. Everything would be as simple as calling:
Enumerable.addMethods(my_hash_of_methods);
if Enumerable was
So, Object.Extend as a side effect would would track the list of
classes that were extended in a hash or something like it. And then
we could revisit that later.
Interesting idea.
But, afaik, currently impossible within Javascript -- let alone
Prototype.
Within Object.extend's scope --
For me, IMHO, of all these 3 I think the first is the nicest looking
this.items.each(this, function(i)
{
alert(this.hello);
});
this.items.each(function(i)
{
alert(this.hello);
}, this);
this.items.each(function(i)
{
alert(this.hello);
}.bind(this));
I just wrote this up in
Completely disagree. First of all, you don't need the parentheses in your
first example. You can simply do stuff like function() {...}.bind(this).
Secondly, in your conclusion you are assuming that you will always _need_ to
correct scope, when in fact you only need to do this if you want to use
On Feb 8, 3:34 pm, Ryan Gahl [EMAIL PROTECTED] wrote:
Completely disagree. First of all, you don't need the parentheses in your
first example. You can simply do stuff like function() {...}.bind(this).
Actually if you run
window.hello = ninja;
var MyClass = Class.create ({
test:
On this point I have to say, It is really hard to extend prototype,
there should be a central registry Object.Extend writes to and I
should not have to write 20 lines of code to change the behavior of
each in all enumerables, it should be possible to do this in one line
of code .
I guess,
Keep in mind also... I'm just one vote. I can't tell you how many times I've
been outvoted here :)
--
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire:
Last I checked, Object.extend doesn't check if a child is defined
before redefining.
So, that shouldn't be too difficult.
Sure, but unless I am missing something .. I have to call
Object.extend on Array.prototype, Hash.prototype, ObjectRange,
Ajax.Responders, Element.ClassNames.prototype to
10 matches
Mail list logo