Subj : Re: spidermonkey ecma extensions To : Martin.Honnen From : Brendan Eich Date : Mon Sep 12 2005 02:43 pm Martin Honnen wrote: > > > steveH wrote: > >> The >> other is the following code >> >> Tokenizer.prototype = { >> get input() { >> return this.source.substring(this.cursor); >> }, >> >> is this use of get documented anywhere, I can see what it's doing - >> defining a property getter, but I don't recall ever seeing it done like >> this before ... FYI, reading http://lxr.mozilla.org/mozilla/source/js/src/jsconfig.h and keeping score of which feature macros are on vs. which are off for JS_VERSION_ECMA_3 vs. JS_VERSION_1_6. > The core JavaScript 1.5 guide has this section > > on getters and setters which also uses the above syntax. > > It is not entirely clear to me whether the above syntax is deprecated It's not deprecated. It was in fact a change from my original getter/setter syntax made at the behest of Waldemar Horwat, to be forward compatible with JS2/ES4. But that was a while ago. /be > or > not in regardance to Mozilla JavaScript but on the web you can't use it > as other engines like the JScript engine in current IE versions or the > engine in Opera will give you a syntax error. > > So on the web you need e.g. > if (typeof Tokenizer.prototype.__defineGetter__ != 'undefined') { > Tokenizer.prototype.__definerGetter__( > 'input', > function () { > return this.source.substring(this.cursor); > } > ); > } > .