Subj : Re: [Rhino] can you add default getters/setters? To : netscape.public.mozilla.jseng From : Mike C. Date : Sat May 08 2004 05:08 am "Igor Bukanov" wrote > Well, if "foo(bar) = something" happens is MS-specific scripts often, it > makes sense to add it to Rhino to improve support for JScript. It would > on the same scale as the implemented support in Rhino for JScript syntax > sugar like > > function object.method() { ... } > which is an alias for > object.method = function () { ... } > This syntax works too in JScript: function object.prototype.method() {...} so you might want to add it if you touch that area. > It would also cover an obscure deviation in Rhino from ECMAScript > standard as "foo(bar) = something" should throw ReferenceError during > script evaluation, not SyntaxError during compilation phase as it > happens now. As Brendan noted, SpiderMonkey supports this as lhs for native functions, I guess it might be usefull if you can add the support in Rhino. It does happen often in MS-specific scripts, take the Session example. If one wants to share the same code base between JScript and Rhino, it is not possible since there are no setter methods for Value in Session, only propput or propputref, that cannot be called directly from scripting languages. So under JScript I can use only Session("foo") = "bar" or manually expand the default setter, as Session.Value("foo") = "bar" If I use Session.Value("foo", "bar") I get runtime error - Wrong number of arguments or invalid property assignment. Note that in the IDL, the Value is declared as [id(00000000), propget] VARIANT Value([in] BSTR bstrValue); [id(00000000), propput] void Value([in] BSTR bstrValue, [in] VARIANT rhs); [id(00000000), propputref] void Value([in] BSTR bstrValue, [in] VARIANT rhs); Unfortunately I don't think I can help since Rhino code is quite complex, and it might take a while for me to get used to its philosophy. I can just pinpoint where the parsing stops, and it is in IRFactory.createAssignment(..). int nodeType = left.getType(); returns Token.CALL, that goes directly to default in the switch, and reports the error. Regards, Mike .