[Helma-user] __defineGetter__ for existing HopObject properties
Joshua Paine
joshua at papercrown.org
Tue Nov 20 19:10:03 CET 2007
Walter Krivanek, VividVisions wrote:
> I can't use __defineGetter__ for properties of a HopObject, which are
> defined in type.properties, can I?
Looks like no. Which is at odds with the treatment of standard
properties. E.g., in Rhino and Firefox 2,
a = { a:'hi' };
a.__defineGetter__('a',function(){ return 'bye'; });
a.a;
the above code returns "bye". But apparently in Firefox 3 you'll have to
delete a.a first before you can define a getter for it (which makes
sense to me). I don't know if that works with HopObjects, and I also
don't know if it would result in that property actually being deleted.
You can't access the stored value of the original property from the
getter anyway, so trying to overload the actual property seems like a
bad idea to me. In one case where I've needed a getter/setter (stored
the value in the DB as an Int unix timestamp, wanted to work with it as
a Date object) I just named the property .modified_ and wrote my getters
and setters for .modified.
-Joshua
More information about the Helma-user
mailing list