objects with "get" properties

George Staikos staikos at kde.org
Fri Jun 13 13:55:35 CEST 2003


   I stumbled across objects with "get" properties in some mozilla JS, and we 
don't currently parse it (gives a parse error).  Does the Apple ScriptCore 
handle it yet?  Here's an example:

var someObject = {
      _someMember : "foo",
      get someProperty() {
               return this._someMember + this._someMember;
      }
};

someObject.someProperty == "foofoo"

   Is this part of the spec, or a Mozilla-ism?

   It was easy to add the parser support for this, but I'm not exactly sure 
what the best approach is to implement this.  Properties seem to explicitly 
have Values as the value (go figure ;)) which doesn't work too well for this 
case.  Should there be a class FunctionValue : public Value  that gets 
executed in the object context whenever its value is requested?  Is there a 
better approach?

-- 
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/



More information about the Khtml-devel mailing list