On Aug 22, 2:11 pm, "Mislav Marohnić" <[EMAIL PROTECTED]>
wrote:
> On 8/22/07, ben <[EMAIL PROTECTED]> wrote:
>
>
>
> > Anyway, to each his own.  I'm guessing your friends balked at the
> > self.prototype.instanceMethod = function() {...} syntax.  That bit can
> > be improved, I think.  If you use the closure as a constructor for the
> > prototype object of the new class, then you can set instance
> > properties by referring to 'this':
>
> > var Person = Class.create(function(self) {
> >     self.classMethod = function() {...};
> >     this.instanceMethod = function() {...};
> > })
>
> Ben,
>
> I'm not completely sold, but am interested. Can you use Pastie to paste some
> example class code? Try to make it look like real world code. Then I suggest
> you point us to that paste in a separate thread. Don't implement, because
> there is no point for you to create diffs before 1.6.0 final is out.

It's actually dead simple to implement this into trunk right now
(hopefully the diff comes through somewhat readable).  All it takes is
a single line of code to make Ben's example work.

I'll try and post a nice real world example in a follow up post,
unless I am beaten to the punch.

Cheers,
Alex Arnell

Index: base.js
===================================================================
--- base.js     (revision 7358)
+++ base.js     (working copy)
@@ -18,6 +18,7 @@
       parent.subclasses.push(klass);
     }

+    if (Object.isFunction(properties)) properties =
(properties.call(klass.prototype, klass) || null);
     if (properties) Class.extend(klass, properties);
     if (!klass.prototype.initialize)
       klass.prototype.initialize = Prototype.emptyFunction;



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" 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/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to