Subj : Re: spidermonkey watch on object.__count__ To : netscape.public.mozilla.jseng From : Jens Thiele Date : Mon Aug 30 2004 06:11 pm Brendan Eich wrote: > You need more hooks than currently exist in the language itself. yes > You could use the jsdbgapi.h, I think. at a first glance it seems to me to be the more complicated aproach >> or should the above work and spidermonkey be fixed? > Nah, __count__ should not impose costs on ordinary property addition. it seems to me this could be done without any additional overhead if no properties are watched (again at a first glance) - and of course it could be done with neglectable overhead ;-) perhaps around jsscope.c:1130 But a better solution for _my_ problem would be to have a generic watch which calls a function whenever an object is changed (property added/deleted/changed) - but then again perhaps I am the only one interested in such functionality and I would have to keep a fork of spidermonkey (which i don't want to) - please don't get me wrong I really understand if you don't want to add this to spidermonkey. pseudo code: w={ add:function(p){perhaps return true or false;} del:function(p){perhaps return true or false;} update:function(p,o,n){return new value;} }; o={}; o.watch(w); or perhaps watch could take three arguments o.watch(addfunc,delfunc,upfunc); or ... I could try to implement something like this if there is enough interest / the possibility to get this into spidermonkey jens .