Subj : Re: [Rhino] can you add default getters/setters? To : Mike C. From : Igor Bukanov Date : Sun May 09 2004 12:33 pm Mike C. wrote: > "Igor Bukanov" wrote > >>>This syntax works too in JScript: >>> function object.prototype.method() {...} >>>so you might want to add it if you touch that area. >> >>Rhino supports that as well. In fact, instead of function name you can >>use arbitrary lvalue. >> > > This syntax didn't work for me, I have compiled with rhino1_5R5. > function foo.prototype.bar(arg) {} > js: "G:\_tests\rhinoTest2.js", line 1: missing ( before function parameters > js: function foo.prototype.bar(arg) > js: .............^ > The feature does not available in Rhino by default as it violates ECMAScript standard. You have to subclass Context to override Context.hasFeature(int featureIndex) to return true when featureIndex is Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME. You may also return true instead of calling super.hasFeature for Context.FEATURE_NON_ECMA_GET_YEAR to emulate JScript in this particular case as well. .... > However note that in the > IE host, you can write > var obj = document.all["foo"]; > It is possible that they use a convention, such as if a property is a > collection, then you can use square brackets instead of call operator, but > I'm not sure. AFAIK in MSIE you can use either foo[bar] or foo(bar) for all collection objects. Regards, Igor .