Subj : Re: SM: Define function and property of the same name? To : JZ From : Brendan Eich Date : Mon Mar 17 2003 05:11 pm JZ wrote: >I'm working on replacing an old proprietary scripting engine with >SpiderMonkey. > >In the old scripting language there are functions and variables of the same >name, for example Year() and Year. > Please say more about this language. Did you have to declare the type of each of these Year overloadings? Was the type always determinuted unambiguously by the use (e.g., calling a function using () vs. getting a property value)? >Is it possible in the JS engine to define both a function and a property of >the same name in the same object? Right now, I get the following returned >when I get the property Year: > >function Year() { > [native code] >} > > You could return an object value for Year that was callable and that has a default value. See JSClass.convert for a starting point. But beware that JS does not support overloading, so the results won't be seamless. /be .