On Jul 3, 10:34 am, "Ryan Gahl" <[EMAIL PROTECTED]> wrote:

> Javascript does not have classes, true. Javascript does have instance
> variables, and does have static members (where in the world are you getting
> this stuff). You're kind of saying "javascript is not object oriented",
> which it is. Does javascript have instances? Yes, otherwise, what is this:
> "var blah = new Foo();"? Are the properties and methods that are unique to
> each instance called instance members? Yes. And what about those members
> that are shared across instances? What's another word for shared, in object
> oriented vernacular? Static. And what we're arguing about is the fact that

Your definition of "static" is what confused me. Why are you calling
shared instance members (where member is property/method) "static"?
Wiki, btw, clearly states that "... a static method cannot refer to a
specific instance of the class (i.e. it cannot refer to this, self,
Me, etc.)..." 
http://en.wikipedia.org/wiki/Method_(computer_science)#Static_methods
That's pretty much what I wrote earlier about "static" members as
understood by majority - it's a member of constructor, not
constructor's prototype (as you refer to).

// constructor
function Person(name) {
  this.name = name;
  Person.count++;
};

// static property (defined directly on a constructor)
Person.count = 0;

// shared instance method
Person.prototype.say = function(message) {
  return this.name + ' says: ' + message;
}

Same goes for prototype.js

var Person = Class.create({
  // constructor
  initialize: function(name) {
    this.name = name;
    Person.count++;
  },
  // shared instance method
  say: function(message) {
    return this.name + ' says: ' + message;
  }
});

// static property
Person.count = 0;

-- kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to